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 139 additions and 69 deletions
Showing only changes of commit 1a4b676635 - Show all commits

View File

@ -2380,6 +2380,44 @@ export type GetShotsWithMetadataQuery = {
};
};
export type ShotFragmentFragment = {
__typename: "ShotGQL";
id: number;
videoId: number;
startFrame: number;
endFrame: number;
falsePositiveScore?: number | null;
createdAt?: any | null;
updatedAt?: any | null;
user?: { __typename: "UserGQL"; id: number } | null;
video?: {
__typename: "VideoGQL";
id: number;
stream?: {
__typename: "UploadStreamGQL";
resolution: {
__typename: "VideoResolutionGQL";
width?: number | null;
height?: number | null;
};
} | null;
} | null;
cueObjectFeatures?: {
__typename: "CueObjectFeaturesGQL";
cueObjectDistance?: number | null;
cueObjectAngle?: number | null;
cueBallSpeed?: number | null;
shotDirection?: ShotDirectionEnum | null;
spinType?: SpinTypeEnum | null;
} | null;
pocketingIntentionFeatures?: {
__typename: "PocketingIntentionFeaturesGQL";
targetPocketDistance?: number | null;
make?: boolean | null;
intendedPocketType?: PocketEnum | null;
} | null;
};
export type GetShotsByIdsQueryVariables = Exact<{
ids: Array<Scalars["Int"]["input"]> | Scalars["Int"]["input"];
includeCreatedAt?: Scalars["Boolean"]["input"];
@ -2399,7 +2437,7 @@ export type GetShotsByIdsQueryVariables = Exact<{
export type GetShotsByIdsQuery = {
__typename?: "Query";
getShotsByIds: Array<{
__typename?: "ShotGQL";
__typename: "ShotGQL";
id: number;
videoId: number;
startFrame: number;
@ -2407,20 +2445,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;
@ -2428,7 +2467,7 @@ export type GetShotsByIdsQuery = {
spinType?: SpinTypeEnum | null;
} | null;
pocketingIntentionFeatures?: {
__typename?: "PocketingIntentionFeaturesGQL";
__typename: "PocketingIntentionFeaturesGQL";
targetPocketDistance?: number | null;
make?: boolean | null;
intendedPocketType?: PocketEnum | null;
@ -2979,6 +3018,48 @@ export type GetUploadStreamsWithDetailsQuery = {
};
};
export const ShotFragmentFragmentDoc = gql`
fragment ShotFragment on ShotGQL {
__typename
id
videoId
startFrame
endFrame
falsePositiveScore
createdAt
updatedAt
user {
__typename
id
}
video {
__typename
id
stream {
__typename
resolution {
__typename
width
height
}
}
}
cueObjectFeatures {
__typename
cueObjectDistance
cueObjectAngle
cueBallSpeed
shotDirection
spinType
}
pocketingIntentionFeatures {
__typename
targetPocketDistance
make
intendedPocketType
}
}
`;
export const GetAggregatedShotMetricsDocument = gql`
query GetAggregatedShotMetrics($aggregateInput: AggregateInputGQL!) {
getAggregatedShotMetrics(aggregateInput: $aggregateInput) {
@ -3768,39 +3849,10 @@ export const GetShotsByIdsDocument = gql`
$includeIntendedPocketType: Boolean! = false
) {
getShotsByIds(ids: $ids) {
id
videoId
startFrame
endFrame
user {
id
}
falsePositiveScore
video {
stream {
resolution {
width
height
}
}
}
createdAt @include(if: $includeCreatedAt)
updatedAt @include(if: $includeUpdatedAt)
cueObjectFeatures @include(if: $includeCueObjectFeatures) {
cueObjectDistance @include(if: $includeCueObjectDistance)
cueObjectAngle @include(if: $includeCueObjectAngle)
cueBallSpeed @include(if: $includeCueBallSpeed)
shotDirection @include(if: $includeShotDirection)
spinType @include(if: $includeSpinType)
}
pocketingIntentionFeatures
@include(if: $includePocketingIntentionFeatures) {
targetPocketDistance @include(if: $includeTargetPocketDistance)
make @include(if: $includeMake)
intendedPocketType @include(if: $includeIntendedPocketType)
}
...ShotFragment
}
}
${ShotFragmentFragmentDoc}
`;
/**

View File

@ -139,6 +139,51 @@ query GetShotsWithMetadata(
}
}
}
# shot.gql
fragment ShotFragment on ShotGQL {
__typename
id
videoId
startFrame
endFrame
falsePositiveScore
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
shotDirection
spinType
}
pocketingIntentionFeatures {
__typename
targetPocketDistance
make
intendedPocketType
}
# Add other nested fields as required
}
query GetShotsByIds(
$ids: [Int!]!
@ -156,36 +201,9 @@ query GetShotsByIds(
$includeIntendedPocketType: Boolean! = false
) {
getShotsByIds(ids: $ids) {
id
videoId
startFrame
endFrame
user {
id
}
falsePositiveScore
video {
stream {
resolution {
width
height
}
}
}
createdAt @include(if: $includeCreatedAt)
updatedAt @include(if: $includeUpdatedAt)
cueObjectFeatures @include(if: $includeCueObjectFeatures) {
cueObjectDistance @include(if: $includeCueObjectDistance)
cueObjectAngle @include(if: $includeCueObjectAngle)
cueBallSpeed @include(if: $includeCueBallSpeed)
shotDirection @include(if: $includeShotDirection)
spinType @include(if: $includeSpinType)
}
pocketingIntentionFeatures
@include(if: $includePocketingIntentionFeatures) {
targetPocketDistance @include(if: $includeTargetPocketDistance)
make @include(if: $includeMake)
intendedPocketType @include(if: $includeIntendedPocketType)
}
...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.
}
}