Skip to content

Commit

Permalink
add homepage statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
RedBeardEth committed Dec 22, 2024
1 parent 7ff7001 commit 67433b2
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 4 deletions.
5 changes: 5 additions & 0 deletions landing/src/hooks/gql/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const documents = {
"\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 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,
"\n query getEntityPosition($entityIds: [u32!]!) {\n s0EternumPositionModels(where: { entity_idIN: $entityIds }) {\n edges {\n node {\n x\n y\n entity_id\n entity {\n __typename\n }\n }\n }\n }\n }\n": types.GetEntityPositionDocument,
"\n query getEntitiesResources($entityIds: [u32!]!) {\n s0EternumResourceModels(\n where: { \n entity_idIN: $entityIds\n }\n limit: 100\n ) {\n edges {\n node {\n entity_id\n resource_type\n balance\n entity {\n __typename\n }\n }\n }\n }\n }\n": types.GetEntitiesResourcesDocument,
};
Expand All @@ -44,6 +45,10 @@ export function graphql(source: "\n query getAccountTokens($accountAddress: Str
* 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 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"): typeof import('./graphql').GetErc721MintsDocument;
/**
* 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 eternumStatistics {\n s0EternumAddressNameModels {\n totalCount\n }\n s0EternumHyperstructureModels {\n totalCount\n }\n s0EternumRealmModels {\n totalCount\n }\n s0EternumFragmentMineDiscoveredModels {\n totalCount\n }\n }\n"): typeof import('./graphql').EternumStatisticsDocument;
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
Expand Down
21 changes: 21 additions & 0 deletions landing/src/hooks/gql/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7298,6 +7298,11 @@ export type GetErc721MintsQueryVariables = Exact<{ [key: string]: never; }>;

export type GetErc721MintsQuery = { __typename?: 'World__Query', tokenTransfers?: { __typename?: 'Token__TransferConnection', edges?: Array<{ __typename?: 'Token__TransferEdge', node?: { __typename?: 'Token__Transfer', tokenMetadata: { __typename: 'ERC20__Token' } | { __typename: 'ERC721__Token', tokenId: string, metadataDescription?: string | null, imagePath: string, contractAddress: string, metadata: string } } | null } | null> | null } | null };

export type EternumStatisticsQueryVariables = Exact<{ [key: string]: never; }>;


export type EternumStatisticsQuery = { __typename?: 'World__Query', s0EternumAddressNameModels?: { __typename?: 's0_eternum_AddressNameConnection', totalCount: number } | null, s0EternumHyperstructureModels?: { __typename?: 's0_eternum_HyperstructureConnection', totalCount: number } | null, s0EternumRealmModels?: { __typename?: 's0_eternum_RealmConnection', totalCount: number } | null, s0EternumFragmentMineDiscoveredModels?: { __typename?: 's0_eternum_FragmentMineDiscoveredConnection', totalCount: number } | null };

export type GetEntityPositionQueryVariables = Exact<{
entityIds: Array<Scalars['u32']['input']> | Scalars['u32']['input'];
}>;
Expand Down Expand Up @@ -7438,6 +7443,22 @@ export const GetErc721MintsDocument = new TypedDocumentString(`
}
}
`) as unknown as TypedDocumentString<GetErc721MintsQuery, GetErc721MintsQueryVariables>;
export const EternumStatisticsDocument = new TypedDocumentString(`
query eternumStatistics {
s0EternumAddressNameModels {
totalCount
}
s0EternumHyperstructureModels {
totalCount
}
s0EternumRealmModels {
totalCount
}
s0EternumFragmentMineDiscoveredModels {
totalCount
}
}
`) as unknown as TypedDocumentString<EternumStatisticsQuery, EternumStatisticsQueryVariables>;
export const GetEntityPositionDocument = new TypedDocumentString(`
query getEntityPosition($entityIds: [u32!]!) {
s0EternumPositionModels(where: {entity_idIN: $entityIds}) {
Expand Down
18 changes: 18 additions & 0 deletions landing/src/hooks/query/eternumStatistics.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { graphql } from "../gql";

export const GET_ETERNUM_STATTISTICS = graphql(`
query eternumStatistics {
s0EternumAddressNameModels {
totalCount
}
s0EternumHyperstructureModels {
totalCount
}
s0EternumRealmModels {
totalCount
}
s0EternumFragmentMineDiscoveredModels {
totalCount
}
}
`);
18 changes: 14 additions & 4 deletions landing/src/routes/index.lazy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ import {
PRIZE_POOL_GUILDS,
PRIZE_POOL_INDIVIDUAL_LEADERBOARD,
} from "@/constants";
import { execute } from "@/hooks/gql/execute";
import { GET_ETERNUM_STATTISTICS } from "@/hooks/query/eternumStatistics";
import { useDonkeysBurned } from "@/hooks/use-donkeys-burned";
import { useLordsBridgeBalance } from "@/hooks/use-lords-bridged";
import { usePlayerCount } from "@/hooks/use-player-count";
import { usePrizePool } from "@/hooks/use-rewards";
import { useStructuresNumber } from "@/hooks/use-structures";
import { currencyFormat, formatNumber } from "@/lib/utils";
import { useQuery } from "@tanstack/react-query";
import { createLazyFileRoute } from "@tanstack/react-router";
import { Castle, Coins, CoinsIcon, Flame, Pickaxe, Sparkles, UsersIcon } from "lucide-react";
import React, { useMemo } from "react";
Expand All @@ -32,6 +35,13 @@ interface GridItemType {
}

function Index() {

const { data, isLoading } = useQuery({
queryKey: ["eternumStatistics"],
queryFn: () => execute(GET_ETERNUM_STATTISTICS),
refetchInterval: 30_000,
});

const donkeysBurned = useDonkeysBurned();
const playerCount = usePlayerCount();
const { realmsCount, hyperstructuresCount, fragmentMinesCount } = useStructuresNumber();
Expand All @@ -46,7 +56,7 @@ function Index() {
rowSpan: { sm: 1, md: 1, lg: 2 },
data: {
title: "players",
value: formatNumber(playerCount, 0),
value: formatNumber(data?.s0EternumAddressNameModels?.totalCount ?? 0, 0),
icon: <UsersIcon />,
backgroundImage: "/images/avatars/Armor.png",
},
Expand All @@ -55,7 +65,7 @@ function Index() {
colSpan: { sm: 2, md: 2, lg: 2 },
data: {
title: "realms settled",
value: formatNumber(realmsCount, 0),
value: formatNumber(data?.s0EternumRealmModels?.totalCount ?? 0, 0),
icon: <Castle />,
backgroundImage: "/images/avatars/Blade.png",
},
Expand All @@ -64,7 +74,7 @@ function Index() {
colSpan: { sm: 2, md: 2, lg: 2 },
data: {
title: "hyperstructures",
value: formatNumber(hyperstructuresCount, 0),
value: formatNumber(data?.s0EternumHyperstructureModels?.totalCount ?? 0, 0),
icon: <Sparkles />,
backgroundImage: "/images/avatars/Hidden.png",
},
Expand All @@ -73,7 +83,7 @@ function Index() {
colSpan: { sm: 2, md: 2, lg: 2 },
data: {
title: "mines discovered",
value: formatNumber(fragmentMinesCount, 0),
value: formatNumber(data?.s0EternumFragmentMineDiscoveredModels?.totalCount ?? 0, 0),
icon: <Pickaxe />,
backgroundImage: "/images/jungle-clouds.png",
},
Expand Down

0 comments on commit 67433b2

Please sign in to comment.