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

View File

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

View File

@ -1,5 +1,7 @@
type Query {
getAggregateShots(bucketSets: [BucketSetInputGQL!]!): [AggregateResultGQL!]!
getAggregatedShotMetrics(
aggregateInput: AggregateInputGQL!
): [AggregateResultGQL!]!
getUser(userId: Int!): UserGQL
getLoggedInUser: UserGQL
getVideo(videoId: Int!): VideoGQL!
@ -31,6 +33,11 @@ type TargetFloatFeatureGQL {
median: Float
}
input AggregateInputGQL {
bucketSets: [BucketSetInputGQL!]!
filterInput: FilterInput
}
input BucketSetInputGQL {
feature: String!
buckets: [BucketInputGQL!]!
@ -41,6 +48,64 @@ input BucketInputGQL {
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 {
id: Int!
firebaseUid: String!
@ -189,64 +254,6 @@ type StreamErrorGQL {
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 {
keyName: String!
feature: String!