diff --git a/src/hooks/queries.tsx b/src/hooks/queries.tsx index d4f2208..4eef6b8 100644 --- a/src/hooks/queries.tsx +++ b/src/hooks/queries.tsx @@ -109,17 +109,25 @@ export const POLLS_FIRST_QUERY = gql` ` const getPollsData = (pageIndex, pageSize, offset, ordering) => { return ` - polls_${pageIndex}: polls(first: ${pageSize}, skip: ${offset}, ${ordering}, where: { id_not_in: [0,1,2,3,6,7,8,9,11] }) { - ...pollsDetail - } + polls_${pageIndex}: polls(first: ${pageSize}, skip: ${offset}, ${ordering}, where: { id_not_in: [0,1,2,3,6,7,8,9,11] }) { + ...pollsDetail + } ` } const getExecutivesData = (pageIndex, pageSize, offset, ordering) => { return ` - executives_${pageIndex}: spells(first: ${pageSize}, skip: ${offset}, ${ordering}) { - ...executivesDetailHome - } + executives_${pageIndex}: spells(first: ${pageSize}, skip: ${offset}, ${ordering}) { + ...executivesDetailHome + } + ` +} + +const getVotersData = (pageIndex, pageSize, offset, ordering) => { + return ` + voters_${pageIndex}: actions(where: { type: VOTER }, first: ${pageSize}, skip: ${offset}, ${ordering}) { + ...actionsDetail + } ` } @@ -143,27 +151,11 @@ const getHomeData = (pageIndex, pageSize, offset, ordering) => { ` } -export const HOME_DATA_QUERY2 = gql` - query getHomeData2($voters: Int!) { - ${getAllEvents(getPollsData, 'startDate')} - ${getAllEvents(getExecutivesData)} - voters: actions(where: { type: VOTER }, first: $voters) { - ...actionsDetail - } - ${getAllEvents(getHomeData)} - } - ${pollsDetailFragment} - ${executivesDetailFragment} - ${actionsDetailFragment} -` - -export const HOME_DATA_QUERY = ({ pollPages, executivesPages }) => gql` - query getHomeData($voters: Int!) { +export const HOME_DATA_QUERY = ({ pollPages, executivesPages, votersPages }) => gql` + query getHomeData { ${getAllEvents(getExecutivesData, 'timestamp', executivesPages)} ${getAllEvents(getPollsData, 'startDate', pollPages)} - voters: actions(where: { type: VOTER }, first: $voters) { - ...actionsDetail - } + ${getAllEvents(getVotersData, 'timestamp', votersPages)} ${getAllEvents(getHomeData)} } ${pollsDetailFragment} diff --git a/src/hooks/useHomeData.tsx b/src/hooks/useHomeData.tsx index 7659d96..ea43049 100644 --- a/src/hooks/useHomeData.tsx +++ b/src/hooks/useHomeData.tsx @@ -7,18 +7,12 @@ import { mergeEventPages } from '../utils' const REACT_APP_HOME_DATA_TTL = Number(process.env.REACT_APP_HOME_DATA_TTL) || 5 -const getHomeVariables = data => { - const governance = data.governanceInfo - return { - voters: Number(governance.countProxies) + Number(governance.countAddresses) || 1000, - } -} - const getPages = gData => { if (!gData) { return { pollPages: 2, executivesPages: 2, + votersPages: 1, } } @@ -26,6 +20,7 @@ const getPages = gData => { return { pollPages: Math.ceil(Number(governanceInfo.countPolls) / 1000), executivesPages: Math.ceil(Number(governanceInfo.countSpells) / 1000), + votersPages: Math.ceil((Number(governanceInfo.countProxies) + Number(governanceInfo.countAddresses)) / 1000), } } @@ -34,7 +29,6 @@ export function useHomeData(governanceInfo: Maybe): any { const [results, setResults] = useState>(null) const [loading, setLoading] = useState(true) const { data, error } = useQuery(HOME_DATA_QUERY(getPages(governanceInfo)), { - variables: governanceInfo && getHomeVariables(governanceInfo), skip: skipQuery, }) diff --git a/src/types/generatedGQL.ts b/src/types/generatedGQL.ts index 1e146ac..cb0c55b 100644 --- a/src/types/generatedGQL.ts +++ b/src/types/generatedGQL.ts @@ -1181,39 +1181,6 @@ export interface getHistoryDataVariables { /* eslint-disable */ // This file was automatically generated and should not be edited. -// ==================================================== -// GraphQL query operation: getHomeData2 -// ==================================================== - -export interface getHomeData2_voters { - __typename: 'Action' - id: string - /** - * Action timestamp as seconds (time) - */ - timestamp: any - /** - * Action value (arg) - */ - wad: any | null - /** - * Action name (act) - */ - type: ActionType -} - -export interface getHomeData2 { - voters: getHomeData2_voters[] -} - -export interface getHomeData2Variables { - voters: number -} - -/* tslint:disable */ -/* eslint-disable */ -// This file was automatically generated and should not be edited. - // ==================================================== // GraphQL fragment: executivesDetailPage // ====================================================