Use shot fragment in getShots to cache normalized shots #64

Merged
kkathuang merged 2 commits from kat/create-shot-fragment into master 2024-10-02 17:38:00 -06:00
2 changed files with 23 additions and 96 deletions
Showing only changes of commit 301c017d5e - Show all commits

View File

@ -2380,8 +2380,8 @@ export type GetShotsWithMetadataQuery = {
}; };
}; };
export type ShotFragmentFragment = { export type ShotWithAllFeaturesFragment = {
__typename: "ShotGQL"; __typename?: "ShotGQL";
id: number; id: number;
videoId: number; videoId: number;
startFrame: number; startFrame: number;
@ -2389,21 +2389,21 @@ export type ShotFragmentFragment = {
falsePositiveScore?: number | null; falsePositiveScore?: number | null;
createdAt?: any | null; createdAt?: any | null;
updatedAt?: any | null; updatedAt?: any | null;
user?: { __typename: "UserGQL"; id: number } | null; user?: { __typename?: "UserGQL"; id: number } | null;
video?: { video?: {
__typename: "VideoGQL"; __typename?: "VideoGQL";
id: number; id: number;
stream?: { stream?: {
__typename: "UploadStreamGQL"; __typename?: "UploadStreamGQL";
resolution: { resolution: {
__typename: "VideoResolutionGQL"; __typename?: "VideoResolutionGQL";
width?: number | null; width?: number | null;
height?: number | null; height?: number | null;
}; };
} | null; } | null;
} | null; } | null;
cueObjectFeatures?: { cueObjectFeatures?: {
__typename: "CueObjectFeaturesGQL"; __typename?: "CueObjectFeaturesGQL";
cueObjectDistance?: number | null; cueObjectDistance?: number | null;
cueObjectAngle?: number | null; cueObjectAngle?: number | null;
cueBallSpeed?: number | null; cueBallSpeed?: number | null;
@ -2411,7 +2411,7 @@ export type ShotFragmentFragment = {
spinType?: SpinTypeEnum | null; spinType?: SpinTypeEnum | null;
} | null; } | null;
pocketingIntentionFeatures?: { pocketingIntentionFeatures?: {
__typename: "PocketingIntentionFeaturesGQL"; __typename?: "PocketingIntentionFeaturesGQL";
targetPocketDistance?: number | null; targetPocketDistance?: number | null;
make?: boolean | null; make?: boolean | null;
intendedPocketType?: PocketEnum | null; intendedPocketType?: PocketEnum | null;
@ -2420,24 +2420,12 @@ export type ShotFragmentFragment = {
export type GetShotsByIdsQueryVariables = Exact<{ export type GetShotsByIdsQueryVariables = Exact<{
ids: Array<Scalars["Int"]["input"]> | Scalars["Int"]["input"]; ids: Array<Scalars["Int"]["input"]> | Scalars["Int"]["input"];
includeCreatedAt?: Scalars["Boolean"]["input"];
includeUpdatedAt?: Scalars["Boolean"]["input"];
includeCueObjectFeatures?: Scalars["Boolean"]["input"];
includePocketingIntentionFeatures?: Scalars["Boolean"]["input"];
includeCueObjectDistance?: Scalars["Boolean"]["input"];
includeCueObjectAngle?: Scalars["Boolean"]["input"];
includeCueBallSpeed?: Scalars["Boolean"]["input"];
includeSpinType?: Scalars["Boolean"]["input"];
includeShotDirection?: Scalars["Boolean"]["input"];
includeTargetPocketDistance?: Scalars["Boolean"]["input"];
includeMake?: Scalars["Boolean"]["input"];
includeIntendedPocketType?: Scalars["Boolean"]["input"];
}>; }>;
export type GetShotsByIdsQuery = { export type GetShotsByIdsQuery = {
__typename?: "Query"; __typename?: "Query";
getShotsByIds: Array<{ getShotsByIds: Array<{
__typename: "ShotGQL"; __typename?: "ShotGQL";
id: number; id: number;
videoId: number; videoId: number;
startFrame: number; startFrame: number;
@ -2445,21 +2433,21 @@ export type GetShotsByIdsQuery = {
falsePositiveScore?: number | null; falsePositiveScore?: number | null;
createdAt?: any | null; createdAt?: any | null;
updatedAt?: any | null; updatedAt?: any | null;
user?: { __typename: "UserGQL"; id: number } | null; user?: { __typename?: "UserGQL"; id: number } | null;
video?: { video?: {
__typename: "VideoGQL"; __typename?: "VideoGQL";
id: number; id: number;
stream?: { stream?: {
__typename: "UploadStreamGQL"; __typename?: "UploadStreamGQL";
resolution: { resolution: {
__typename: "VideoResolutionGQL"; __typename?: "VideoResolutionGQL";
width?: number | null; width?: number | null;
height?: number | null; height?: number | null;
}; };
} | null; } | null;
} | null; } | null;
cueObjectFeatures?: { cueObjectFeatures?: {
__typename: "CueObjectFeaturesGQL"; __typename?: "CueObjectFeaturesGQL";
cueObjectDistance?: number | null; cueObjectDistance?: number | null;
cueObjectAngle?: number | null; cueObjectAngle?: number | null;
cueBallSpeed?: number | null; cueBallSpeed?: number | null;
@ -2467,7 +2455,7 @@ export type GetShotsByIdsQuery = {
spinType?: SpinTypeEnum | null; spinType?: SpinTypeEnum | null;
} | null; } | null;
pocketingIntentionFeatures?: { pocketingIntentionFeatures?: {
__typename: "PocketingIntentionFeaturesGQL"; __typename?: "PocketingIntentionFeaturesGQL";
targetPocketDistance?: number | null; targetPocketDistance?: number | null;
make?: boolean | null; make?: boolean | null;
intendedPocketType?: PocketEnum | null; intendedPocketType?: PocketEnum | null;
@ -3018,9 +3006,8 @@ export type GetUploadStreamsWithDetailsQuery = {
}; };
}; };
export const ShotFragmentFragmentDoc = gql` export const ShotWithAllFeaturesFragmentDoc = gql`
fragment ShotFragment on ShotGQL { fragment ShotWithAllFeatures on ShotGQL {
__typename
id id
videoId videoId
startFrame startFrame
@ -3029,23 +3016,18 @@ export const ShotFragmentFragmentDoc = gql`
createdAt createdAt
updatedAt updatedAt
user { user {
__typename
id id
} }
video { video {
__typename
id id
stream { stream {
__typename
resolution { resolution {
__typename
width width
height height
} }
} }
} }
cueObjectFeatures { cueObjectFeatures {
__typename
cueObjectDistance cueObjectDistance
cueObjectAngle cueObjectAngle
cueBallSpeed cueBallSpeed
@ -3053,7 +3035,6 @@ export const ShotFragmentFragmentDoc = gql`
spinType spinType
} }
pocketingIntentionFeatures { pocketingIntentionFeatures {
__typename
targetPocketDistance targetPocketDistance
make make
intendedPocketType intendedPocketType
@ -3833,26 +3814,12 @@ export type GetShotsWithMetadataQueryResult = Apollo.QueryResult<
GetShotsWithMetadataQueryVariables GetShotsWithMetadataQueryVariables
>; >;
export const GetShotsByIdsDocument = gql` export const GetShotsByIdsDocument = gql`
query GetShotsByIds( query GetShotsByIds($ids: [Int!]!) {
$ids: [Int!]!
$includeCreatedAt: Boolean! = false
$includeUpdatedAt: Boolean! = false
$includeCueObjectFeatures: Boolean! = false
$includePocketingIntentionFeatures: Boolean! = false
$includeCueObjectDistance: Boolean! = false
$includeCueObjectAngle: Boolean! = false
$includeCueBallSpeed: Boolean! = false
$includeSpinType: Boolean! = false
$includeShotDirection: Boolean! = false
$includeTargetPocketDistance: Boolean! = false
$includeMake: Boolean! = false
$includeIntendedPocketType: Boolean! = false
) {
getShotsByIds(ids: $ids) { getShotsByIds(ids: $ids) {
...ShotFragment ...ShotWithAllFeatures
} }
} }
${ShotFragmentFragmentDoc} ${ShotWithAllFeaturesFragmentDoc}
`; `;
/** /**
@ -3868,18 +3835,6 @@ export const GetShotsByIdsDocument = gql`
* const { data, loading, error } = useGetShotsByIdsQuery({ * const { data, loading, error } = useGetShotsByIdsQuery({
* variables: { * variables: {
* ids: // value for 'ids' * ids: // value for 'ids'
* includeCreatedAt: // value for 'includeCreatedAt'
* includeUpdatedAt: // value for 'includeUpdatedAt'
* includeCueObjectFeatures: // value for 'includeCueObjectFeatures'
* includePocketingIntentionFeatures: // value for 'includePocketingIntentionFeatures'
* includeCueObjectDistance: // value for 'includeCueObjectDistance'
* includeCueObjectAngle: // value for 'includeCueObjectAngle'
* includeCueBallSpeed: // value for 'includeCueBallSpeed'
* includeSpinType: // value for 'includeSpinType'
* includeShotDirection: // value for 'includeShotDirection'
* includeTargetPocketDistance: // value for 'includeTargetPocketDistance'
* includeMake: // value for 'includeMake'
* includeIntendedPocketType: // value for 'includeIntendedPocketType'
* }, * },
* }); * });
*/ */

View File

@ -139,10 +139,8 @@ query GetShotsWithMetadata(
} }
} }
} }
# shot.gql
fragment ShotFragment on ShotGQL { fragment ShotWithAllFeatures on ShotGQL {
__typename
id id
videoId videoId
startFrame startFrame
@ -151,25 +149,18 @@ fragment ShotFragment on ShotGQL {
createdAt createdAt
updatedAt updatedAt
user { user {
__typename
id id
# Add other necessary fields from UserGql if needed
} }
video { video {
__typename
id id
# Add other necessary fields from VideoGql if needed
stream { stream {
__typename
resolution { resolution {
__typename
width width
height height
} }
} }
} }
cueObjectFeatures { cueObjectFeatures {
__typename
cueObjectDistance cueObjectDistance
cueObjectAngle cueObjectAngle
cueBallSpeed cueBallSpeed
@ -177,33 +168,14 @@ fragment ShotFragment on ShotGQL {
spinType spinType
} }
pocketingIntentionFeatures { pocketingIntentionFeatures {
__typename
targetPocketDistance targetPocketDistance
make make
intendedPocketType intendedPocketType
} }
# Add other nested fields as required
} }
query GetShotsByIds( query GetShotsByIds($ids: [Int!]!) {
$ids: [Int!]!
$includeCreatedAt: Boolean! = false
$includeUpdatedAt: Boolean! = false
$includeCueObjectFeatures: Boolean! = false
$includePocketingIntentionFeatures: Boolean! = false
$includeCueObjectDistance: Boolean! = false
$includeCueObjectAngle: Boolean! = false
$includeCueBallSpeed: Boolean! = false
$includeSpinType: Boolean! = false
$includeShotDirection: Boolean! = false
$includeTargetPocketDistance: Boolean! = false
$includeMake: Boolean! = false
$includeIntendedPocketType: Boolean! = false
) {
getShotsByIds(ids: $ids) { getShotsByIds(ids: $ids) {
...ShotFragment ...ShotWithAllFeatures
# Since the fragment already includes all necessary fields,
# you can remove the conditional fields from the query itself.
# Alternatively, if you still need conditional fields, handle them within the fragment.
} }
} }