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 = {
__typename: "ShotGQL";
export type ShotWithAllFeaturesFragment = {
__typename?: "ShotGQL";
id: number;
videoId: number;
startFrame: number;
@ -2389,21 +2389,21 @@ export type ShotFragmentFragment = {
falsePositiveScore?: number | null;
createdAt?: any | null;
updatedAt?: any | null;
user?: { __typename: "UserGQL"; id: number } | null;
user?: { __typename?: "UserGQL"; id: number } | null;
video?: {
__typename: "VideoGQL";
__typename?: "VideoGQL";
id: number;
stream?: {
__typename: "UploadStreamGQL";
__typename?: "UploadStreamGQL";
resolution: {
__typename: "VideoResolutionGQL";
__typename?: "VideoResolutionGQL";
width?: number | null;
height?: number | null;
};
} | null;
} | null;
cueObjectFeatures?: {
__typename: "CueObjectFeaturesGQL";
__typename?: "CueObjectFeaturesGQL";
cueObjectDistance?: number | null;
cueObjectAngle?: number | null;
cueBallSpeed?: number | null;
@ -2411,7 +2411,7 @@ export type ShotFragmentFragment = {
spinType?: SpinTypeEnum | null;
} | null;
pocketingIntentionFeatures?: {
__typename: "PocketingIntentionFeaturesGQL";
__typename?: "PocketingIntentionFeaturesGQL";
targetPocketDistance?: number | null;
make?: boolean | null;
intendedPocketType?: PocketEnum | null;
@ -2420,24 +2420,12 @@ export type ShotFragmentFragment = {
export type GetShotsByIdsQueryVariables = Exact<{
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 = {
__typename?: "Query";
getShotsByIds: Array<{
__typename: "ShotGQL";
__typename?: "ShotGQL";
id: number;
videoId: number;
startFrame: number;
@ -2445,21 +2433,21 @@ export type GetShotsByIdsQuery = {
falsePositiveScore?: number | null;
createdAt?: any | null;
updatedAt?: any | null;
user?: { __typename: "UserGQL"; id: number } | null;
user?: { __typename?: "UserGQL"; id: number } | null;
video?: {
__typename: "VideoGQL";
__typename?: "VideoGQL";
id: number;
stream?: {
__typename: "UploadStreamGQL";
__typename?: "UploadStreamGQL";
resolution: {
__typename: "VideoResolutionGQL";
__typename?: "VideoResolutionGQL";
width?: number | null;
height?: number | null;
};
} | null;
} | null;
cueObjectFeatures?: {
__typename: "CueObjectFeaturesGQL";
__typename?: "CueObjectFeaturesGQL";
cueObjectDistance?: number | null;
cueObjectAngle?: number | null;
cueBallSpeed?: number | null;
@ -2467,7 +2455,7 @@ export type GetShotsByIdsQuery = {
spinType?: SpinTypeEnum | null;
} | null;
pocketingIntentionFeatures?: {
__typename: "PocketingIntentionFeaturesGQL";
__typename?: "PocketingIntentionFeaturesGQL";
targetPocketDistance?: number | null;
make?: boolean | null;
intendedPocketType?: PocketEnum | null;
@ -3018,9 +3006,8 @@ export type GetUploadStreamsWithDetailsQuery = {
};
};
export const ShotFragmentFragmentDoc = gql`
fragment ShotFragment on ShotGQL {
__typename
export const ShotWithAllFeaturesFragmentDoc = gql`
fragment ShotWithAllFeatures on ShotGQL {
id
videoId
startFrame
@ -3029,23 +3016,18 @@ export const ShotFragmentFragmentDoc = gql`
createdAt
updatedAt
user {
__typename
id
}
video {
__typename
id
stream {
__typename
resolution {
__typename
width
height
}
}
}
cueObjectFeatures {
__typename
cueObjectDistance
cueObjectAngle
cueBallSpeed
@ -3053,7 +3035,6 @@ export const ShotFragmentFragmentDoc = gql`
spinType
}
pocketingIntentionFeatures {
__typename
targetPocketDistance
make
intendedPocketType
@ -3833,26 +3814,12 @@ export type GetShotsWithMetadataQueryResult = Apollo.QueryResult<
GetShotsWithMetadataQueryVariables
>;
export const GetShotsByIdsDocument = gql`
query GetShotsByIds(
$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
) {
query GetShotsByIds($ids: [Int!]!) {
getShotsByIds(ids: $ids) {
...ShotFragment
...ShotWithAllFeatures
}
}
${ShotFragmentFragmentDoc}
${ShotWithAllFeaturesFragmentDoc}
`;
/**
@ -3868,18 +3835,6 @@ export const GetShotsByIdsDocument = gql`
* const { data, loading, error } = useGetShotsByIdsQuery({
* variables: {
* 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 {
__typename
fragment ShotWithAllFeatures on ShotGQL {
id
videoId
startFrame
@ -151,25 +149,18 @@ fragment ShotFragment on ShotGQL {
createdAt
updatedAt
user {
__typename
id
# Add other necessary fields from UserGql if needed
}
video {
__typename
id
# Add other necessary fields from VideoGql if needed
stream {
__typename
resolution {
__typename
width
height
}
}
}
cueObjectFeatures {
__typename
cueObjectDistance
cueObjectAngle
cueBallSpeed
@ -177,33 +168,14 @@ fragment ShotFragment on ShotGQL {
spinType
}
pocketingIntentionFeatures {
__typename
targetPocketDistance
make
intendedPocketType
}
# Add other nested fields as required
}
query GetShotsByIds(
$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
) {
query GetShotsByIds($ids: [Int!]!) {
getShotsByIds(ids: $ids) {
...ShotFragment
# 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.
...ShotWithAllFeatures
}
}