From 17aee8f2207d38b0cde2e151bf772ef0f8c3a7c6 Mon Sep 17 00:00:00 2001 From: Kat Huang Date: Wed, 21 Feb 2024 17:44:24 -0700 Subject: [PATCH 1/2] Drop frame count from videl gql --- src/index.tsx | 3 +-- src/schema.gql | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 8fdf86e..811f0c4 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -342,7 +342,7 @@ export type VideoGql = { __typename?: 'VideoGQL'; averageTimeBetweenShots?: Maybe; createdAt: Scalars['DateTime']['output']; - elapsedTime: Scalars['Float']['output']; + elapsedTime?: Maybe; endTime: Scalars['DateTime']['output']; framesPerSecond: Scalars['Int']['output']; id: Scalars['Int']['output']; @@ -352,7 +352,6 @@ export type VideoGql = { shots: Array; startTime: Scalars['DateTime']['output']; stream?: Maybe; - totalFrames: Scalars['Int']['output']; totalShots: Scalars['Int']['output']; totalShotsMade: Scalars['Int']['output']; updatedAt: Scalars['DateTime']['output']; diff --git a/src/schema.gql b/src/schema.gql index 2537d4c..81d8a35 100644 --- a/src/schema.gql +++ b/src/schema.gql @@ -77,9 +77,8 @@ type VideoGQL { shots: [ShotGQL!]! startTime: DateTime! endTime: DateTime! - elapsedTime: Float! + elapsedTime: Float framesPerSecond: Int! - totalFrames: Int! stream: UploadStreamGQL } From 60af058ba4b5dd23bacd0183d7831d92aed1bb2b Mon Sep 17 00:00:00 2001 From: Kat Huang Date: Wed, 21 Feb 2024 19:13:30 -0700 Subject: [PATCH 2/2] Create feed --- src/index.tsx | 96 +++++++++++++++++++++++++++++++++++++++++ src/operations/feed.gql | 48 +++++++++++++++++++++ 2 files changed, 144 insertions(+) create mode 100644 src/operations/feed.gql diff --git a/src/index.tsx b/src/index.tsx index 811f0c4..b46cc9f 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -369,6 +369,21 @@ export type GetAggregateShotsQueryVariables = Exact<{ export type GetAggregateShotsQuery = { __typename?: 'Query', getAggregateShots: Array<{ __typename?: 'AggregateResultGQL', featureBuckets: Array<{ __typename?: 'BucketGQL', rangeKey: string, lowerBound: number }>, targetMetrics: Array<{ __typename?: 'TargetMetricGQL', count?: number | null, makePercentage?: number | null, floatFeature?: { __typename?: 'TargetFloatFeatureGQL', featureName: string, average?: number | null, median?: number | null } | null }> }> }; +export type GetFeedQueryVariables = Exact<{ + first?: Scalars['Int']['input']; + after?: InputMaybe; + includeTotalShotsMade?: Scalars['Boolean']['input']; + includeMakePercentage?: Scalars['Boolean']['input']; + includeMedianRun?: Scalars['Boolean']['input']; + includeAverageTimeBetweenShots?: Scalars['Boolean']['input']; + includeElapsedTime?: Scalars['Boolean']['input']; + includeFramesPerSecond?: Scalars['Boolean']['input']; + includeStream?: Scalars['Boolean']['input']; +}>; + + +export type GetFeedQuery = { __typename?: 'Query', getVideoFeedForUser: { __typename?: 'VideoFeedGQL', videos: Array<{ __typename?: 'VideoGQL', id: number, name: string, totalShotsMade?: number, totalShots: number, makePercentage?: number, medianRun?: number | null, averageTimeBetweenShots?: number | null, createdAt: any, updatedAt: any, startTime: any, endTime: any, elapsedTime?: number | null, shots: Array<{ __typename?: 'ShotGQL', id?: number | null, videoId?: number | null, startFrame?: number | null, endFrame?: number | null, createdAt?: any | null, updatedAt?: any | null }>, stream?: { __typename?: 'UploadStreamGQL', id: string, linksRequested: number, uploadsCompleted: number, isCompleted: boolean, createdAt: any, updatedAt: any } | null }>, pageInfo: { __typename?: 'PageInfoGQL', hasNextPage: boolean, endCursor?: string | null } } }; + export type GetShotsQueryVariables = Exact<{ filterInput?: InputMaybe; includeCueObjectDistance?: Scalars['Boolean']['input']; @@ -470,6 +485,87 @@ export type GetAggregateShotsQueryHookResult = ReturnType; export type GetAggregateShotsSuspenseQueryHookResult = ReturnType; export type GetAggregateShotsQueryResult = Apollo.QueryResult; +export const GetFeedDocument = gql` + query GetFeed($first: Int! = 5, $after: String = null, $includeTotalShotsMade: Boolean! = false, $includeMakePercentage: Boolean! = false, $includeMedianRun: Boolean! = false, $includeAverageTimeBetweenShots: Boolean! = false, $includeElapsedTime: Boolean! = false, $includeFramesPerSecond: Boolean! = false, $includeStream: Boolean! = false) { + getVideoFeedForUser(first: $first, after: $after) { + videos { + id + name + totalShotsMade @include(if: $includeTotalShotsMade) + totalShots + makePercentage @include(if: $includeMakePercentage) + medianRun @include(if: $includeMedianRun) + averageTimeBetweenShots @include(if: $includeAverageTimeBetweenShots) + createdAt + updatedAt + shots { + id + videoId + startFrame + endFrame + createdAt + updatedAt + } + startTime + endTime + elapsedTime @include(if: $includeElapsedTime) + stream @include(if: $includeStream) { + id + linksRequested + uploadsCompleted + isCompleted + createdAt + updatedAt + } + } + pageInfo { + hasNextPage + endCursor + } + } +} + `; + +/** + * __useGetFeedQuery__ + * + * To run a query within a React component, call `useGetFeedQuery` and pass it any options that fit your needs. + * When your component renders, `useGetFeedQuery` 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 } = useGetFeedQuery({ + * variables: { + * first: // value for 'first' + * after: // value for 'after' + * includeTotalShotsMade: // value for 'includeTotalShotsMade' + * includeMakePercentage: // value for 'includeMakePercentage' + * includeMedianRun: // value for 'includeMedianRun' + * includeAverageTimeBetweenShots: // value for 'includeAverageTimeBetweenShots' + * includeElapsedTime: // value for 'includeElapsedTime' + * includeFramesPerSecond: // value for 'includeFramesPerSecond' + * includeStream: // value for 'includeStream' + * }, + * }); + */ +export function useGetFeedQuery(baseOptions?: Apollo.QueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useQuery(GetFeedDocument, options); + } +export function useGetFeedLazyQuery(baseOptions?: Apollo.LazyQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useLazyQuery(GetFeedDocument, options); + } +export function useGetFeedSuspenseQuery(baseOptions?: Apollo.SuspenseQueryHookOptions) { + const options = {...defaultOptions, ...baseOptions} + return Apollo.useSuspenseQuery(GetFeedDocument, options); + } +export type GetFeedQueryHookResult = ReturnType; +export type GetFeedLazyQueryHookResult = ReturnType; +export type GetFeedSuspenseQueryHookResult = ReturnType; +export type GetFeedQueryResult = Apollo.QueryResult; export const GetShotsDocument = gql` query GetShots($filterInput: FilterInput, $includeCueObjectDistance: Boolean! = false, $includeCueObjectAngle: Boolean! = false, $includeCueBallSpeed: Boolean! = false, $includeShotDirection: Boolean! = false, $includeTargetPocketDistance: Boolean! = false, $includeMake: Boolean! = false, $includeIntendedPocketType: Boolean! = false) { getShots(filterInput: $filterInput) { diff --git a/src/operations/feed.gql b/src/operations/feed.gql new file mode 100644 index 0000000..0a2425b --- /dev/null +++ b/src/operations/feed.gql @@ -0,0 +1,48 @@ +query GetFeed( + $first: Int! = 5, + $after: String = null, + $includeTotalShotsMade: Boolean! = false, + $includeMakePercentage: Boolean! = false, + $includeMedianRun: Boolean! = false, + $includeAverageTimeBetweenShots: Boolean! = false, + $includeElapsedTime: Boolean! = false, + $includeFramesPerSecond: Boolean! = false, + $includeStream: Boolean! = false +) { + getVideoFeedForUser(first: $first, after: $after) { + videos { + id + name + totalShotsMade @include(if: $includeTotalShotsMade) + totalShots + makePercentage @include(if: $includeMakePercentage) + medianRun @include(if: $includeMedianRun) + averageTimeBetweenShots @include(if: $includeAverageTimeBetweenShots) + createdAt + updatedAt + shots { + id + videoId + startFrame + endFrame + createdAt + updatedAt + } + startTime + endTime + elapsedTime @include(if: $includeElapsedTime) + stream @include(if: $includeStream) { + id + linksRequested + uploadsCompleted + isCompleted + createdAt + updatedAt + } + } + pageInfo { + hasNextPage + endCursor + } + } +}