Add filtering support to aggregate gql

This commit is contained in:
Ivan Malison 2024-03-09 10:21:43 -07:00
parent 19628736c1
commit fd30ae04bf
3 changed files with 115 additions and 103 deletions

View File

@ -34,6 +34,11 @@ export type Scalars = {
Decimal: { input: any; output: any }; Decimal: { input: any; output: any };
}; };
export type AggregateInputGql = {
bucketSets: Array<BucketSetInputGql>;
filterInput?: InputMaybe<FilterInput>;
};
export type AggregateResultGql = { export type AggregateResultGql = {
__typename?: "AggregateResultGQL"; __typename?: "AggregateResultGQL";
featureBuckets: Array<BucketGql>; featureBuckets: Array<BucketGql>;
@ -238,7 +243,7 @@ export type PocketingIntentionFeaturesGql = {
export type Query = { export type Query = {
__typename?: "Query"; __typename?: "Query";
getAggregateShots: Array<AggregateResultGql>; getAggregatedShotMetrics: Array<AggregateResultGql>;
getBucketSet?: Maybe<BucketSetGql>; getBucketSet?: Maybe<BucketSetGql>;
getLoggedInUser?: Maybe<UserGql>; getLoggedInUser?: Maybe<UserGql>;
getShots: Array<ShotGql>; getShots: Array<ShotGql>;
@ -248,8 +253,8 @@ export type Query = {
getVideoMakePercentageIntervals: Array<MakePercentageIntervalGql>; getVideoMakePercentageIntervals: Array<MakePercentageIntervalGql>;
}; };
export type QueryGetAggregateShotsArgs = { export type QueryGetAggregatedShotMetricsArgs = {
bucketSets: Array<BucketSetInputGql>; aggregateInput: AggregateInputGql;
}; };
export type QueryGetBucketSetArgs = { export type QueryGetBucketSetArgs = {
@ -424,13 +429,13 @@ export enum WallTypeEnum {
Short = "SHORT", Short = "SHORT",
} }
export type GetAggregateShotsQueryVariables = Exact<{ export type GetAggregatedShotMetricsQueryVariables = Exact<{
bucketSets: Array<BucketSetInputGql> | BucketSetInputGql; aggregateInput: AggregateInputGql;
}>; }>;
export type GetAggregateShotsQuery = { export type GetAggregatedShotMetricsQuery = {
__typename?: "Query"; __typename?: "Query";
getAggregateShots: Array<{ getAggregatedShotMetrics: Array<{
__typename?: "AggregateResultGQL"; __typename?: "AggregateResultGQL";
featureBuckets: Array<{ featureBuckets: Array<{
__typename?: "BucketGQL"; __typename?: "BucketGQL";
@ -594,9 +599,9 @@ export type TerminateUploadStreamMutation = {
terminateUploadStream: boolean; terminateUploadStream: boolean;
}; };
export const GetAggregateShotsDocument = gql` export const GetAggregatedShotMetricsDocument = gql`
query GetAggregateShots($bucketSets: [BucketSetInputGQL!]!) { query GetAggregatedShotMetrics($aggregateInput: AggregateInputGQL!) {
getAggregateShots(bucketSets: $bucketSets) { getAggregatedShotMetrics(aggregateInput: $aggregateInput) {
featureBuckets { featureBuckets {
rangeKey rangeKey
lowerBound lowerBound
@ -615,69 +620,69 @@ export const GetAggregateShotsDocument = gql`
`; `;
/** /**
* __useGetAggregateShotsQuery__ * __useGetAggregatedShotMetricsQuery__
* *
* To run a query within a React component, call `useGetAggregateShotsQuery` and pass it any options that fit your needs. * To run a query within a React component, call `useGetAggregatedShotMetricsQuery` and pass it any options that fit your needs.
* When your component renders, `useGetAggregateShotsQuery` returns an object from Apollo Client that contains loading, error, and data properties * When your component renders, `useGetAggregatedShotMetricsQuery` returns an object from Apollo Client that contains loading, error, and data properties
* you can use to render your UI. * 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; * @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 * @example
* const { data, loading, error } = useGetAggregateShotsQuery({ * const { data, loading, error } = useGetAggregatedShotMetricsQuery({
* variables: { * variables: {
* bucketSets: // value for 'bucketSets' * aggregateInput: // value for 'aggregateInput'
* }, * },
* }); * });
*/ */
export function useGetAggregateShotsQuery( export function useGetAggregatedShotMetricsQuery(
baseOptions: Apollo.QueryHookOptions< baseOptions: Apollo.QueryHookOptions<
GetAggregateShotsQuery, GetAggregatedShotMetricsQuery,
GetAggregateShotsQueryVariables GetAggregatedShotMetricsQueryVariables
>, >,
) { ) {
const options = { ...defaultOptions, ...baseOptions }; const options = { ...defaultOptions, ...baseOptions };
return Apollo.useQuery< return Apollo.useQuery<
GetAggregateShotsQuery, GetAggregatedShotMetricsQuery,
GetAggregateShotsQueryVariables GetAggregatedShotMetricsQueryVariables
>(GetAggregateShotsDocument, options); >(GetAggregatedShotMetricsDocument, options);
} }
export function useGetAggregateShotsLazyQuery( export function useGetAggregatedShotMetricsLazyQuery(
baseOptions?: Apollo.LazyQueryHookOptions< baseOptions?: Apollo.LazyQueryHookOptions<
GetAggregateShotsQuery, GetAggregatedShotMetricsQuery,
GetAggregateShotsQueryVariables GetAggregatedShotMetricsQueryVariables
>, >,
) { ) {
const options = { ...defaultOptions, ...baseOptions }; const options = { ...defaultOptions, ...baseOptions };
return Apollo.useLazyQuery< return Apollo.useLazyQuery<
GetAggregateShotsQuery, GetAggregatedShotMetricsQuery,
GetAggregateShotsQueryVariables GetAggregatedShotMetricsQueryVariables
>(GetAggregateShotsDocument, options); >(GetAggregatedShotMetricsDocument, options);
} }
export function useGetAggregateShotsSuspenseQuery( export function useGetAggregatedShotMetricsSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions< baseOptions?: Apollo.SuspenseQueryHookOptions<
GetAggregateShotsQuery, GetAggregatedShotMetricsQuery,
GetAggregateShotsQueryVariables GetAggregatedShotMetricsQueryVariables
>, >,
) { ) {
const options = { ...defaultOptions, ...baseOptions }; const options = { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery< return Apollo.useSuspenseQuery<
GetAggregateShotsQuery, GetAggregatedShotMetricsQuery,
GetAggregateShotsQueryVariables GetAggregatedShotMetricsQueryVariables
>(GetAggregateShotsDocument, options); >(GetAggregatedShotMetricsDocument, options);
} }
export type GetAggregateShotsQueryHookResult = ReturnType< export type GetAggregatedShotMetricsQueryHookResult = ReturnType<
typeof useGetAggregateShotsQuery typeof useGetAggregatedShotMetricsQuery
>; >;
export type GetAggregateShotsLazyQueryHookResult = ReturnType< export type GetAggregatedShotMetricsLazyQueryHookResult = ReturnType<
typeof useGetAggregateShotsLazyQuery typeof useGetAggregatedShotMetricsLazyQuery
>; >;
export type GetAggregateShotsSuspenseQueryHookResult = ReturnType< export type GetAggregatedShotMetricsSuspenseQueryHookResult = ReturnType<
typeof useGetAggregateShotsSuspenseQuery typeof useGetAggregatedShotMetricsSuspenseQuery
>; >;
export type GetAggregateShotsQueryResult = Apollo.QueryResult< export type GetAggregatedShotMetricsQueryResult = Apollo.QueryResult<
GetAggregateShotsQuery, GetAggregatedShotMetricsQuery,
GetAggregateShotsQueryVariables GetAggregatedShotMetricsQueryVariables
>; >;
export const GetFeedDocument = gql` export const GetFeedDocument = gql`
query GetFeed($limit: Int! = 5, $after: String = null) { query GetFeed($limit: Int! = 5, $after: String = null) {

View File

@ -1,5 +1,5 @@
query GetAggregateShots($bucketSets: [BucketSetInputGQL!]!) { query GetAggregatedShotMetrics($aggregateInput: AggregateInputGQL!) {
getAggregateShots(bucketSets: $bucketSets) { getAggregatedShotMetrics(aggregateInput: $aggregateInput) {
featureBuckets { featureBuckets {
rangeKey rangeKey
lowerBound lowerBound

View File

@ -1,5 +1,7 @@
type Query { type Query {
getAggregateShots(bucketSets: [BucketSetInputGQL!]!): [AggregateResultGQL!]! getAggregatedShotMetrics(
aggregateInput: AggregateInputGQL!
): [AggregateResultGQL!]!
getUser(userId: Int!): UserGQL getUser(userId: Int!): UserGQL
getLoggedInUser: UserGQL getLoggedInUser: UserGQL
getVideo(videoId: Int!): VideoGQL! getVideo(videoId: Int!): VideoGQL!
@ -31,6 +33,11 @@ type TargetFloatFeatureGQL {
median: Float median: Float
} }
input AggregateInputGQL {
bucketSets: [BucketSetInputGQL!]!
filterInput: FilterInput
}
input BucketSetInputGQL { input BucketSetInputGQL {
feature: String! feature: String!
buckets: [BucketInputGQL!]! buckets: [BucketInputGQL!]!
@ -41,6 +48,64 @@ input BucketInputGQL {
lowerBound: Float! lowerBound: Float!
} }
input FilterInput {
andFilters: AndFilter = null
orFilters: OrFilter = null
cueObjectDistance: CueObjectDistanceInput = null
targetPocketDistance: TargetPocketDistanceInput = null
cueObjectAngle: CueObjectAngleInput = null
cueBallSpeed: CueBallSpeedInput = null
intendedPocketType: IntendedPocketTypeInput = null
shotDirection: ShotDirectionInput = null
videoId: InListFilter = null
userId: InListFilter = null
}
input AndFilter {
filters: [FilterInput!]!
}
input OrFilter {
filters: [FilterInput!]!
}
input CueObjectDistanceInput {
value: RangeFilter!
}
input RangeFilter {
lessThan: Float = null
greaterThanEqualTo: Float = null
}
input TargetPocketDistanceInput {
value: RangeFilter!
}
input CueObjectAngleInput {
value: RangeFilter!
}
input CueBallSpeedInput {
value: RangeFilter!
}
input IntendedPocketTypeInput {
value: EnumFilter!
}
input EnumFilter {
equals: String = null
}
input ShotDirectionInput {
value: EnumFilter!
}
input InListFilter {
inList: [Int!] = null
}
type UserGQL { type UserGQL {
id: Int! id: Int!
firebaseUid: String! firebaseUid: String!
@ -189,64 +254,6 @@ type StreamErrorGQL {
message: String! message: String!
} }
input FilterInput {
andFilters: AndFilter = null
orFilters: OrFilter = null
cueObjectDistance: CueObjectDistanceInput = null
targetPocketDistance: TargetPocketDistanceInput = null
cueObjectAngle: CueObjectAngleInput = null
cueBallSpeed: CueBallSpeedInput = null
intendedPocketType: IntendedPocketTypeInput = null
shotDirection: ShotDirectionInput = null
videoId: InListFilter = null
userId: InListFilter = null
}
input AndFilter {
filters: [FilterInput!]!
}
input OrFilter {
filters: [FilterInput!]!
}
input CueObjectDistanceInput {
value: RangeFilter!
}
input RangeFilter {
lessThan: Float = null
greaterThanEqualTo: Float = null
}
input TargetPocketDistanceInput {
value: RangeFilter!
}
input CueObjectAngleInput {
value: RangeFilter!
}
input CueBallSpeedInput {
value: RangeFilter!
}
input IntendedPocketTypeInput {
value: EnumFilter!
}
input EnumFilter {
equals: String = null
}
input ShotDirectionInput {
value: EnumFilter!
}
input InListFilter {
inList: [Int!] = null
}
type BucketSetGQL { type BucketSetGQL {
keyName: String! keyName: String!
feature: String! feature: String!