diff --git a/landing/src/hooks/gql/gql.ts b/landing/src/hooks/gql/gql.ts index c5e6f510a..c82d4a94c 100644 --- a/landing/src/hooks/gql/gql.ts +++ b/landing/src/hooks/gql/gql.ts @@ -17,7 +17,7 @@ import * as types from './graphql'; const documents = { "\n query getCapacitySpeedConfig($category: Enum!, $entityType: u32!) {\n s0EternumCapacityConfigModels(where: {category: $category }) {\n edges{\n node {\n weight_gram\n }\n }\n }\n s0EternumSpeedConfigModels(where: {entity_type: $entityType }) {\n edges{\n node {\n sec_per_km\n }\n }\n }\n }\n": types.GetCapacitySpeedConfigDocument, "\n query getEternumOwnerRealmIds($accountAddress: ContractAddress!) {\n s0EternumOwnerModels(where: { address: $accountAddress }, limit: 8000) {\n edges {\n node {\n address\n entity_id\n entity {\n models {\n __typename\n ... on s0_eternum_Realm {\n realm_id\n }\n }\n }\n }\n }\n }\n }\n": types.GetEternumOwnerRealmIdsDocument, - "\n query getEternumEntityOwner($entityOwnerIds: [u32!]!) {\n s0EternumEntityOwnerModels(where: { entity_owner_idIN: $entityOwnerIds}, limit: 200) {\n edges {\n node {\n entity_id\n entity_owner_id\n entity {\n models {\n __typename\n ... on s0_eternum_OwnedResourcesTracker {\n resource_types\n }\n ... on s0_eternum_Position {\n x\n y\n }\n ... on s0_eternum_ArrivalTime {\n arrives_at\n }\n ... on s0_eternum_Weight {\n value\n }\n }\n }\n }\n }\n }\n }\n": types.GetEternumEntityOwnerDocument, + "\n query getEternumEntityOwner($entityOwnerIds: [u32!]!) {\n s0EternumEntityOwnerModels(where: { entity_owner_idIN: $entityOwnerIds}, limit: 10000) {\n edges {\n node {\n entity_id\n entity_owner_id\n entity {\n models {\n __typename\n ... on s0_eternum_OwnedResourcesTracker {\n resource_types\n }\n ... on s0_eternum_Position {\n x\n y\n }\n ... on s0_eternum_ArrivalTime {\n arrives_at\n }\n ... on s0_eternum_Weight {\n value\n }\n }\n }\n }\n }\n }\n }\n": types.GetEternumEntityOwnerDocument, "\n query getAccountTokens($accountAddress: String!) {\n tokenBalances(accountAddress: $accountAddress, limit: 8000) {\n edges {\n node {\n tokenMetadata {\n __typename\n ... on ERC721__Token {\n tokenId\n metadataDescription\n imagePath\n contractAddress\n metadata\n }\n }\n }\n }\n }\n }\n": types.GetAccountTokensDocument, "\n query getERC721Mints {\n tokenTransfers(accountAddress: \"0x0\", limit: 8000) {\n edges {\n node {\n tokenMetadata {\n __typename\n ... on ERC721__Token {\n tokenId\n metadataDescription\n imagePath\n contractAddress\n metadata\n }\n }\n }\n }\n }\n }\n": types.GetErc721MintsDocument, "\n query eternumStatistics {\n s0EternumAddressNameModels {\n totalCount\n }\n s0EternumHyperstructureModels {\n totalCount\n }\n s0EternumRealmModels {\n totalCount\n }\n s0EternumFragmentMineDiscoveredModels {\n totalCount\n }\n }\n": types.EternumStatisticsDocument, @@ -43,7 +43,7 @@ export function graphql(source: "\n query getEternumOwnerRealmIds($accountAddre /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ -export function graphql(source: "\n query getEternumEntityOwner($entityOwnerIds: [u32!]!) {\n s0EternumEntityOwnerModels(where: { entity_owner_idIN: $entityOwnerIds}, limit: 200) {\n edges {\n node {\n entity_id\n entity_owner_id\n entity {\n models {\n __typename\n ... on s0_eternum_OwnedResourcesTracker {\n resource_types\n }\n ... on s0_eternum_Position {\n x\n y\n }\n ... on s0_eternum_ArrivalTime {\n arrives_at\n }\n ... on s0_eternum_Weight {\n value\n }\n }\n }\n }\n }\n }\n }\n"): typeof import('./graphql').GetEternumEntityOwnerDocument; +export function graphql(source: "\n query getEternumEntityOwner($entityOwnerIds: [u32!]!) {\n s0EternumEntityOwnerModels(where: { entity_owner_idIN: $entityOwnerIds}, limit: 10000) {\n edges {\n node {\n entity_id\n entity_owner_id\n entity {\n models {\n __typename\n ... on s0_eternum_OwnedResourcesTracker {\n resource_types\n }\n ... on s0_eternum_Position {\n x\n y\n }\n ... on s0_eternum_ArrivalTime {\n arrives_at\n }\n ... on s0_eternum_Weight {\n value\n }\n }\n }\n }\n }\n }\n }\n"): typeof import('./graphql').GetEternumEntityOwnerDocument; /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ diff --git a/landing/src/hooks/gql/graphql.ts b/landing/src/hooks/gql/graphql.ts index eaf9eef59..e9ada9682 100644 --- a/landing/src/hooks/gql/graphql.ts +++ b/landing/src/hooks/gql/graphql.ts @@ -7417,7 +7417,7 @@ export const GetEternumEntityOwnerDocument = new TypedDocumentString(` query getEternumEntityOwner($entityOwnerIds: [u32!]!) { s0EternumEntityOwnerModels( where: {entity_owner_idIN: $entityOwnerIds} - limit: 200 + limit: 10000 ) { edges { node { diff --git a/landing/src/hooks/helpers/useDonkeyArrivals.tsx b/landing/src/hooks/helpers/useDonkeyArrivals.tsx index a51a64c1c..735fddf9b 100644 --- a/landing/src/hooks/helpers/useDonkeyArrivals.tsx +++ b/landing/src/hooks/helpers/useDonkeyArrivals.tsx @@ -8,6 +8,8 @@ import { GET_ETERNUM_ENTITY_OWNERS } from "../query/entityOwners"; import { GET_ENTITY_DISTANCE } from "../query/position"; import { GET_ENTITIES_RESOURCES } from "../query/resources"; +const BATCH_SIZE = 5; + export function useDonkeyArrivals(realmEntityIds: ID[]) { const { data: entityPositions, @@ -29,12 +31,21 @@ export function useDonkeyArrivals(realmEntityIds: ID[]) { // refetchInterval: 10_000, // }); + const batchedRealmIds = useMemo(() => { + const batches = []; + for (let i = 0; i < realmEntityIds.length; i += BATCH_SIZE) { + batches.push(realmEntityIds.slice(i, i + BATCH_SIZE)); + } + return batches; + }, [realmEntityIds]); + + const donkeyQueriesResults = useQueries({ - queries: realmEntityIds.map((realmId) => ({ - queryKey: ["donkeyEntityIds", realmId], - queryFn: () => execute(GET_ETERNUM_ENTITY_OWNERS, { entityOwnerIds: [realmId] }), - enabled: !!realmId, - refetchInterval: 100_000, + queries: batchedRealmIds.map((realmIds) => ({ + queryKey: ["donkeyEntityIds", realmIds], + queryFn: () => execute(GET_ETERNUM_ENTITY_OWNERS, { entityOwnerIds: realmIds }), + enabled: !!realmIds, + staleTime: 5 * 60 * 1000, })), }); diff --git a/landing/src/hooks/query/entityOwners.tsx b/landing/src/hooks/query/entityOwners.tsx index 5e7754be1..70b2410fb 100644 --- a/landing/src/hooks/query/entityOwners.tsx +++ b/landing/src/hooks/query/entityOwners.tsx @@ -2,7 +2,7 @@ import { graphql } from "../gql"; export const GET_ETERNUM_ENTITY_OWNERS = graphql(` query getEternumEntityOwner($entityOwnerIds: [u32!]!) { - s0EternumEntityOwnerModels(where: { entity_owner_idIN: $entityOwnerIds}, limit: 200) { + s0EternumEntityOwnerModels(where: { entity_owner_idIN: $entityOwnerIds}, limit: 10000) { edges { node { entity_id