From c53d4d75ff1a5ddb40a565d72e176d84240411f3 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Fri, 20 Sep 2024 13:02:02 -0600 Subject: [PATCH] Make range filters generic --- src/index.tsx | 142 ++++++++++++++++++++++++++++++--------- src/operations/shots.gql | 1 + src/schema.gql | 47 ++++++++----- 3 files changed, 144 insertions(+), 46 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index fada181..267435b 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -28,6 +28,8 @@ export type Scalars = { Boolean: { input: boolean; output: boolean }; Int: { input: number; output: number }; Float: { input: number; output: number }; + /** Date (isoformat) */ + Date: { input: any; output: any }; /** Date with time (isoformat) */ DateTime: { input: any; output: any }; /** The `JSON` scalar type represents JSON values as specified by [ECMA-404](https://ecma-international.org/wp-content/uploads/ECMA-404_2nd_edition_december_2017.pdf). */ @@ -132,6 +134,15 @@ export type CueObjectFeaturesGql = { spinType?: Maybe; }; +export type DateGenericRangeFilter = { + greaterThan?: InputMaybe; + greaterThanEqualTo?: InputMaybe; + greaterThanInclusive?: Scalars["Boolean"]["input"]; + includeOnNone?: Scalars["Boolean"]["input"]; + lessThan?: InputMaybe; + lessThanInclusive?: Scalars["Boolean"]["input"]; +}; + export type DatetimeRangeAggregationInput = { endDatetime: Scalars["DateTime"]["input"]; interval: TimeInterval; @@ -174,6 +185,7 @@ export type FilterInput = backcut?: never; bankAngle?: never; bankDistance?: never; + createdAt?: never; cueAngleAfterObject?: never; cueBallSpeed?: never; cueObjectAngle?: never; @@ -210,6 +222,7 @@ export type FilterInput = backcut?: never; bankAngle?: never; bankDistance?: never; + createdAt?: never; cueAngleAfterObject?: never; cueBallSpeed?: never; cueObjectAngle?: never; @@ -246,6 +259,7 @@ export type FilterInput = backcut: Array; bankAngle?: never; bankDistance?: never; + createdAt?: never; cueAngleAfterObject?: never; cueBallSpeed?: never; cueObjectAngle?: never; @@ -280,8 +294,9 @@ export type FilterInput = andFilters?: never; annotations?: never; backcut?: never; - bankAngle: RangeFilter; + bankAngle: FloatGenericRangeFilter; bankDistance?: never; + createdAt?: never; cueAngleAfterObject?: never; cueBallSpeed?: never; cueObjectAngle?: never; @@ -317,7 +332,8 @@ export type FilterInput = annotations?: never; backcut?: never; bankAngle?: never; - bankDistance: RangeFilter; + bankDistance: FloatGenericRangeFilter; + createdAt?: never; cueAngleAfterObject?: never; cueBallSpeed?: never; cueObjectAngle?: never; @@ -354,7 +370,8 @@ export type FilterInput = backcut?: never; bankAngle?: never; bankDistance?: never; - cueAngleAfterObject: RangeFilter; + createdAt: DateGenericRangeFilter; + cueAngleAfterObject?: never; cueBallSpeed?: never; cueObjectAngle?: never; cueObjectDistance?: never; @@ -390,8 +407,9 @@ export type FilterInput = backcut?: never; bankAngle?: never; bankDistance?: never; - cueAngleAfterObject?: never; - cueBallSpeed: RangeFilter; + createdAt?: never; + cueAngleAfterObject: FloatGenericRangeFilter; + cueBallSpeed?: never; cueObjectAngle?: never; cueObjectDistance?: never; cueSpeedAfterObject?: never; @@ -426,9 +444,10 @@ export type FilterInput = backcut?: never; bankAngle?: never; bankDistance?: never; + createdAt?: never; cueAngleAfterObject?: never; - cueBallSpeed?: never; - cueObjectAngle: RangeFilter; + cueBallSpeed: FloatGenericRangeFilter; + cueObjectAngle?: never; cueObjectDistance?: never; cueSpeedAfterObject?: never; difficulty?: never; @@ -462,10 +481,11 @@ export type FilterInput = backcut?: never; bankAngle?: never; bankDistance?: never; + createdAt?: never; cueAngleAfterObject?: never; cueBallSpeed?: never; - cueObjectAngle?: never; - cueObjectDistance: RangeFilter; + cueObjectAngle: FloatGenericRangeFilter; + cueObjectDistance?: never; cueSpeedAfterObject?: never; difficulty?: never; falsePositiveScore?: never; @@ -498,11 +518,12 @@ export type FilterInput = backcut?: never; bankAngle?: never; bankDistance?: never; + createdAt?: never; cueAngleAfterObject?: never; cueBallSpeed?: never; cueObjectAngle?: never; - cueObjectDistance?: never; - cueSpeedAfterObject: RangeFilter; + cueObjectDistance: FloatGenericRangeFilter; + cueSpeedAfterObject?: never; difficulty?: never; falsePositiveScore?: never; intendedPocketType?: never; @@ -534,12 +555,13 @@ export type FilterInput = backcut?: never; bankAngle?: never; bankDistance?: never; + createdAt?: never; cueAngleAfterObject?: never; cueBallSpeed?: never; cueObjectAngle?: never; cueObjectDistance?: never; - cueSpeedAfterObject?: never; - difficulty: RangeFilter; + cueSpeedAfterObject: FloatGenericRangeFilter; + difficulty?: never; falsePositiveScore?: never; intendedPocketType?: never; isDirect?: never; @@ -570,13 +592,14 @@ export type FilterInput = backcut?: never; bankAngle?: never; bankDistance?: never; + createdAt?: never; cueAngleAfterObject?: never; cueBallSpeed?: never; cueObjectAngle?: never; cueObjectDistance?: never; cueSpeedAfterObject?: never; - difficulty?: never; - falsePositiveScore: RangeFilter; + difficulty: FloatGenericRangeFilter; + falsePositiveScore?: never; intendedPocketType?: never; isDirect?: never; isLeft?: never; @@ -606,6 +629,44 @@ export type FilterInput = backcut?: never; bankAngle?: never; bankDistance?: never; + createdAt?: never; + cueAngleAfterObject?: never; + cueBallSpeed?: never; + cueObjectAngle?: never; + cueObjectDistance?: never; + cueSpeedAfterObject?: never; + difficulty?: never; + falsePositiveScore: FloatGenericRangeFilter; + intendedPocketType?: never; + isDirect?: never; + isLeft?: never; + isLeftMiss?: never; + isRight?: never; + isRightMiss?: never; + isStraight?: never; + kickAngle?: never; + kickDistance?: never; + make?: never; + missAngleInDegrees?: never; + notFilter?: never; + orFilters?: never; + shotDirection?: never; + spinType?: never; + tableSize?: never; + tags?: never; + targetPocketAngle?: never; + targetPocketAngleDirection?: never; + targetPocketDistance?: never; + userId?: never; + videoId?: never; + } + | { + andFilters?: never; + annotations?: never; + backcut?: never; + bankAngle?: never; + bankDistance?: never; + createdAt?: never; cueAngleAfterObject?: never; cueBallSpeed?: never; cueObjectAngle?: never; @@ -642,6 +703,7 @@ export type FilterInput = backcut?: never; bankAngle?: never; bankDistance?: never; + createdAt?: never; cueAngleAfterObject?: never; cueBallSpeed?: never; cueObjectAngle?: never; @@ -678,6 +740,7 @@ export type FilterInput = backcut?: never; bankAngle?: never; bankDistance?: never; + createdAt?: never; cueAngleAfterObject?: never; cueBallSpeed?: never; cueObjectAngle?: never; @@ -714,6 +777,7 @@ export type FilterInput = backcut?: never; bankAngle?: never; bankDistance?: never; + createdAt?: never; cueAngleAfterObject?: never; cueBallSpeed?: never; cueObjectAngle?: never; @@ -750,6 +814,7 @@ export type FilterInput = backcut?: never; bankAngle?: never; bankDistance?: never; + createdAt?: never; cueAngleAfterObject?: never; cueBallSpeed?: never; cueObjectAngle?: never; @@ -786,6 +851,7 @@ export type FilterInput = backcut?: never; bankAngle?: never; bankDistance?: never; + createdAt?: never; cueAngleAfterObject?: never; cueBallSpeed?: never; cueObjectAngle?: never; @@ -822,6 +888,7 @@ export type FilterInput = backcut?: never; bankAngle?: never; bankDistance?: never; + createdAt?: never; cueAngleAfterObject?: never; cueBallSpeed?: never; cueObjectAngle?: never; @@ -858,6 +925,7 @@ export type FilterInput = backcut?: never; bankAngle?: never; bankDistance?: never; + createdAt?: never; cueAngleAfterObject?: never; cueBallSpeed?: never; cueObjectAngle?: never; @@ -872,7 +940,7 @@ export type FilterInput = isRight?: never; isRightMiss?: never; isStraight?: never; - kickAngle: RangeFilter; + kickAngle: FloatGenericRangeFilter; kickDistance?: never; make?: never; missAngleInDegrees?: never; @@ -894,6 +962,7 @@ export type FilterInput = backcut?: never; bankAngle?: never; bankDistance?: never; + createdAt?: never; cueAngleAfterObject?: never; cueBallSpeed?: never; cueObjectAngle?: never; @@ -909,7 +978,7 @@ export type FilterInput = isRightMiss?: never; isStraight?: never; kickAngle?: never; - kickDistance: RangeFilter; + kickDistance: FloatGenericRangeFilter; make?: never; missAngleInDegrees?: never; notFilter?: never; @@ -930,6 +999,7 @@ export type FilterInput = backcut?: never; bankAngle?: never; bankDistance?: never; + createdAt?: never; cueAngleAfterObject?: never; cueBallSpeed?: never; cueObjectAngle?: never; @@ -966,6 +1036,7 @@ export type FilterInput = backcut?: never; bankAngle?: never; bankDistance?: never; + createdAt?: never; cueAngleAfterObject?: never; cueBallSpeed?: never; cueObjectAngle?: never; @@ -983,7 +1054,7 @@ export type FilterInput = kickAngle?: never; kickDistance?: never; make?: never; - missAngleInDegrees: RangeFilter; + missAngleInDegrees: FloatGenericRangeFilter; notFilter?: never; orFilters?: never; shotDirection?: never; @@ -1002,6 +1073,7 @@ export type FilterInput = backcut?: never; bankAngle?: never; bankDistance?: never; + createdAt?: never; cueAngleAfterObject?: never; cueBallSpeed?: never; cueObjectAngle?: never; @@ -1038,6 +1110,7 @@ export type FilterInput = backcut?: never; bankAngle?: never; bankDistance?: never; + createdAt?: never; cueAngleAfterObject?: never; cueBallSpeed?: never; cueObjectAngle?: never; @@ -1074,6 +1147,7 @@ export type FilterInput = backcut?: never; bankAngle?: never; bankDistance?: never; + createdAt?: never; cueAngleAfterObject?: never; cueBallSpeed?: never; cueObjectAngle?: never; @@ -1110,6 +1184,7 @@ export type FilterInput = backcut?: never; bankAngle?: never; bankDistance?: never; + createdAt?: never; cueAngleAfterObject?: never; cueBallSpeed?: never; cueObjectAngle?: never; @@ -1146,6 +1221,7 @@ export type FilterInput = backcut?: never; bankAngle?: never; bankDistance?: never; + createdAt?: never; cueAngleAfterObject?: never; cueBallSpeed?: never; cueObjectAngle?: never; @@ -1168,7 +1244,7 @@ export type FilterInput = orFilters?: never; shotDirection?: never; spinType?: never; - tableSize: RangeFilter; + tableSize: FloatGenericRangeFilter; tags?: never; targetPocketAngle?: never; targetPocketAngleDirection?: never; @@ -1182,6 +1258,7 @@ export type FilterInput = backcut?: never; bankAngle?: never; bankDistance?: never; + createdAt?: never; cueAngleAfterObject?: never; cueBallSpeed?: never; cueObjectAngle?: never; @@ -1218,6 +1295,7 @@ export type FilterInput = backcut?: never; bankAngle?: never; bankDistance?: never; + createdAt?: never; cueAngleAfterObject?: never; cueBallSpeed?: never; cueObjectAngle?: never; @@ -1242,7 +1320,7 @@ export type FilterInput = spinType?: never; tableSize?: never; tags?: never; - targetPocketAngle: RangeFilter; + targetPocketAngle: FloatGenericRangeFilter; targetPocketAngleDirection?: never; targetPocketDistance?: never; userId?: never; @@ -1254,6 +1332,7 @@ export type FilterInput = backcut?: never; bankAngle?: never; bankDistance?: never; + createdAt?: never; cueAngleAfterObject?: never; cueBallSpeed?: never; cueObjectAngle?: never; @@ -1290,6 +1369,7 @@ export type FilterInput = backcut?: never; bankAngle?: never; bankDistance?: never; + createdAt?: never; cueAngleAfterObject?: never; cueBallSpeed?: never; cueObjectAngle?: never; @@ -1316,7 +1396,7 @@ export type FilterInput = tags?: never; targetPocketAngle?: never; targetPocketAngleDirection?: never; - targetPocketDistance: RangeFilter; + targetPocketDistance: FloatGenericRangeFilter; userId?: never; videoId?: never; } @@ -1326,6 +1406,7 @@ export type FilterInput = backcut?: never; bankAngle?: never; bankDistance?: never; + createdAt?: never; cueAngleAfterObject?: never; cueBallSpeed?: never; cueObjectAngle?: never; @@ -1362,6 +1443,7 @@ export type FilterInput = backcut?: never; bankAngle?: never; bankDistance?: never; + createdAt?: never; cueAngleAfterObject?: never; cueBallSpeed?: never; cueObjectAngle?: never; @@ -1393,6 +1475,15 @@ export type FilterInput = videoId: Array; }; +export type FloatGenericRangeFilter = { + greaterThan?: InputMaybe; + greaterThanEqualTo?: InputMaybe; + greaterThanInclusive?: Scalars["Boolean"]["input"]; + includeOnNone?: Scalars["Boolean"]["input"]; + lessThan?: InputMaybe; + lessThanInclusive?: Scalars["Boolean"]["input"]; +}; + export type GetProfileUploadLinkErrors = { __typename?: "GetProfileUploadLinkErrors"; error: TooManyProfileImageUploadsErr; @@ -1709,15 +1800,6 @@ export type QueryWaitForArgs = { duration: Scalars["Float"]["input"]; }; -export type RangeFilter = { - greaterThan?: InputMaybe; - greaterThanEqualTo?: InputMaybe; - greaterThanInclusive?: Scalars["Boolean"]["input"]; - includeOnNone?: Scalars["Boolean"]["input"]; - lessThan?: InputMaybe; - lessThanInclusive?: Scalars["Boolean"]["input"]; -}; - export type SegmentAlreadyUploadedErr = { __typename?: "SegmentAlreadyUploadedErr"; segmentId: Scalars["Int"]["output"]; diff --git a/src/operations/shots.gql b/src/operations/shots.gql index 545443c..7249449 100644 --- a/src/operations/shots.gql +++ b/src/operations/shots.gql @@ -116,6 +116,7 @@ query GetShotsWithMetadata( serializedShotPaths { b64EncodedBuffer } + createdAt @include(if: $includeCreatedAt) updatedAt @include(if: $includeUpdatedAt) cueObjectFeatures @include(if: $includeCueObjectFeatures) { diff --git a/src/schema.gql b/src/schema.gql index 310c284..a224561 100644 --- a/src/schema.gql +++ b/src/schema.gql @@ -131,11 +131,11 @@ input FilterInput @oneOf { andFilters: [FilterInput!] orFilters: [FilterInput!] notFilter: FilterInput - cueObjectDistance: RangeFilter - targetPocketDistance: RangeFilter - cueObjectAngle: RangeFilter - cueBallSpeed: RangeFilter - difficulty: RangeFilter + cueObjectDistance: FloatGenericRangeFilter + targetPocketDistance: FloatGenericRangeFilter + cueObjectAngle: FloatGenericRangeFilter + cueBallSpeed: FloatGenericRangeFilter + difficulty: FloatGenericRangeFilter intendedPocketType: [PocketEnum!] shotDirection: [ShotDirectionEnum!] videoId: [Int!] @@ -149,22 +149,23 @@ input FilterInput @oneOf { isLeftMiss: [Boolean!] isRightMiss: [Boolean!] isDirect: [Boolean!] - tableSize: RangeFilter - bankAngle: RangeFilter - bankDistance: RangeFilter - kickAngle: RangeFilter - kickDistance: RangeFilter - cueAngleAfterObject: RangeFilter + tableSize: FloatGenericRangeFilter + bankAngle: FloatGenericRangeFilter + bankDistance: FloatGenericRangeFilter + kickAngle: FloatGenericRangeFilter + kickDistance: FloatGenericRangeFilter + cueAngleAfterObject: FloatGenericRangeFilter spinType: [SpinTypeEnum!] - cueSpeedAfterObject: RangeFilter - falsePositiveScore: RangeFilter + cueSpeedAfterObject: FloatGenericRangeFilter + falsePositiveScore: FloatGenericRangeFilter backcut: [Boolean!] targetPocketAngleDirection: [ShotDirectionEnum!] - targetPocketAngle: RangeFilter - missAngleInDegrees: RangeFilter + targetPocketAngle: FloatGenericRangeFilter + missAngleInDegrees: FloatGenericRangeFilter + createdAt: DateGenericRangeFilter } -input RangeFilter { +input FloatGenericRangeFilter { lessThan: Float = null greaterThanEqualTo: Float = null greaterThan: Float = null @@ -204,6 +205,20 @@ enum SpinTypeEnum { UNKNOWN } +input DateGenericRangeFilter { + lessThan: Date = null + greaterThanEqualTo: Date = null + greaterThan: Date = null + includeOnNone: Boolean! = false + lessThanInclusive: Boolean! = false + greaterThanInclusive: Boolean! = true +} + +""" +Date (isoformat) +""" +scalar Date + type BucketSetGQL { keyName: String! feature: String!