From 881350619a1816a4617441fc288eb7b9c28fe27a Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Mon, 23 Dec 2024 13:55:14 -0700 Subject: [PATCH] Add get longest runs operation --- src/index.tsx | 105 ++++++++++++++++++++++++++++++++ src/operations/leaderboards.gql | 14 +++++ 2 files changed, 119 insertions(+) diff --git a/src/index.tsx b/src/index.tsx index f28a67b..0d62a43 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -3115,6 +3115,29 @@ export type GetMakesLeaderboardQuery = { }; }; +export type GetRunsLeaderboardQueryVariables = Exact<{ + interval?: InputMaybe; + when?: InputMaybe; +}>; + +export type GetRunsLeaderboardQuery = { + __typename?: "Query"; + getLongestRunsLeaderboard: { + __typename?: "RunLeaderboardGQL"; + entries: Array<{ + __typename?: "RunGQL"; + id: number; + runLength: number; + user: { + __typename?: "UserGQL"; + id: number; + username: string; + profileImageUri?: string | null; + }; + }>; + }; +}; + export type GetVideoMakePercentageIntervalsQueryVariables = Exact<{ videoId: Scalars["ID"]["input"]; intervalDuration: Scalars["Int"]["input"]; @@ -5235,6 +5258,88 @@ export type GetMakesLeaderboardQueryResult = Apollo.QueryResult< GetMakesLeaderboardQuery, GetMakesLeaderboardQueryVariables >; +export const GetRunsLeaderboardDocument = gql` + query GetRunsLeaderboard($interval: TimeInterval, $when: DateTime) { + getLongestRunsLeaderboard(interval: $interval, when: $when) { + entries { + id + runLength + user { + id + username + profileImageUri + } + } + } + } +`; + +/** + * __useGetRunsLeaderboardQuery__ + * + * To run a query within a React component, call `useGetRunsLeaderboardQuery` and pass it any options that fit your needs. + * When your component renders, `useGetRunsLeaderboardQuery` returns an object from Apollo Client that contains loading, error, and data properties + * you can use to render your UI. + * + * @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options; + * + * @example + * const { data, loading, error } = useGetRunsLeaderboardQuery({ + * variables: { + * interval: // value for 'interval' + * when: // value for 'when' + * }, + * }); + */ +export function useGetRunsLeaderboardQuery( + baseOptions?: Apollo.QueryHookOptions< + GetRunsLeaderboardQuery, + GetRunsLeaderboardQueryVariables + >, +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useQuery< + GetRunsLeaderboardQuery, + GetRunsLeaderboardQueryVariables + >(GetRunsLeaderboardDocument, options); +} +export function useGetRunsLeaderboardLazyQuery( + baseOptions?: Apollo.LazyQueryHookOptions< + GetRunsLeaderboardQuery, + GetRunsLeaderboardQueryVariables + >, +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useLazyQuery< + GetRunsLeaderboardQuery, + GetRunsLeaderboardQueryVariables + >(GetRunsLeaderboardDocument, options); +} +export function useGetRunsLeaderboardSuspenseQuery( + baseOptions?: Apollo.SuspenseQueryHookOptions< + GetRunsLeaderboardQuery, + GetRunsLeaderboardQueryVariables + >, +) { + const options = { ...defaultOptions, ...baseOptions }; + return Apollo.useSuspenseQuery< + GetRunsLeaderboardQuery, + GetRunsLeaderboardQueryVariables + >(GetRunsLeaderboardDocument, options); +} +export type GetRunsLeaderboardQueryHookResult = ReturnType< + typeof useGetRunsLeaderboardQuery +>; +export type GetRunsLeaderboardLazyQueryHookResult = ReturnType< + typeof useGetRunsLeaderboardLazyQuery +>; +export type GetRunsLeaderboardSuspenseQueryHookResult = ReturnType< + typeof useGetRunsLeaderboardSuspenseQuery +>; +export type GetRunsLeaderboardQueryResult = Apollo.QueryResult< + GetRunsLeaderboardQuery, + GetRunsLeaderboardQueryVariables +>; export const GetVideoMakePercentageIntervalsDocument = gql` query GetVideoMakePercentageIntervals( $videoId: ID! diff --git a/src/operations/leaderboards.gql b/src/operations/leaderboards.gql index 2c6449e..ee5c437 100644 --- a/src/operations/leaderboards.gql +++ b/src/operations/leaderboards.gql @@ -12,3 +12,17 @@ query GetMakesLeaderboard($interval: TimeInterval, $when: DateTime) { } } } + +query GetRunsLeaderboard($interval: TimeInterval, $when: DateTime) { + getLongestRunsLeaderboard(interval: $interval, when: $when) { + entries { + id + runLength + user { + id + username + profileImageUri + } + } + } +}