Skip to content

Commit

Permalink
Add ability to find scene updated times by id list
Browse files Browse the repository at this point in the history
  • Loading branch information
ikmckenz committed Dec 21, 2024
1 parent c898ef4 commit b2d0a3d
Show file tree
Hide file tree
Showing 9 changed files with 481 additions and 2 deletions.
6 changes: 6 additions & 0 deletions frontend/src/graphql/queries/ScenesUpdates.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
query ScenesUpdates($ids: [ID!]!) {
findScenesUpdates(ids: $ids) {
ids
updated
}
}
79 changes: 79 additions & 0 deletions frontend/src/graphql/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,8 @@ export type Query = {
/** @deprecated Use findScenesBySceneFingerprints */
findScenesByFullFingerprints: Array<Scene>;
findScenesBySceneFingerprints: Array<Array<Scene>>;
/** Find scene updated time by ID */
findScenesUpdates?: Maybe<QueryScenesUpdatesResult>;
/** Find an external site by ID */
findSite?: Maybe<Site>;
/** Find a studio by ID or name */
Expand Down Expand Up @@ -1255,6 +1257,11 @@ export type QueryFindScenesBySceneFingerprintsArgs = {
fingerprints: Array<Array<FingerprintQueryInput>>;
};

/** The query root for this schema */
export type QueryFindScenesUpdatesArgs = {
ids: Array<Scalars["ID"]["input"]>;
};

/** The query root for this schema */
export type QueryFindSiteArgs = {
id: Scalars["ID"]["input"];
Expand Down Expand Up @@ -1410,6 +1417,12 @@ export type QueryScenesResultType = {
scenes: Array<Scene>;
};

export type QueryScenesUpdatesResult = {
__typename: "QueryScenesUpdatesResult";
ids: Array<Scalars["ID"]["output"]>;
updated: Array<Scalars["Time"]["output"]>;
};

export type QuerySitesResultType = {
__typename: "QuerySitesResultType";
count: Scalars["Int"]["output"];
Expand Down Expand Up @@ -29957,6 +29970,18 @@ export type ScenesQuery = {
};
};

export type ScenesUpdatesQueryVariables = Exact<{
ids: Array<Scalars["ID"]["input"]> | Scalars["ID"]["input"];
}>;

export type ScenesUpdatesQuery = {
__typename: "Query";
findScenesUpdates?: {
__typename: "QueryScenesUpdatesResult";
ids: Array<string>;
} | null;
};

export type ScenesWithFingerprintsQueryVariables = Exact<{
input: SceneQueryInput;
submitted: Scalars["Boolean"]["input"];
Expand Down Expand Up @@ -65258,6 +65283,60 @@ export const ScenesDocument = {
},
],
} as unknown as DocumentNode<ScenesQuery, ScenesQueryVariables>;
export const ScenesUpdatesDocument = {
kind: "Document",
definitions: [
{
kind: "OperationDefinition",
operation: "query",
name: { kind: "Name", value: "ScenesUpdates" },
variableDefinitions: [
{
kind: "VariableDefinition",
variable: { kind: "Variable", name: { kind: "Name", value: "ids" } },
type: {
kind: "NonNullType",
type: {
kind: "ListType",
type: {
kind: "NonNullType",
type: {
kind: "NamedType",
name: { kind: "Name", value: "ID" },
},
},
},
},
},
],
selectionSet: {
kind: "SelectionSet",
selections: [
{
kind: "Field",
name: { kind: "Name", value: "findScenesUpdates" },
arguments: [
{
kind: "Argument",
name: { kind: "Name", value: "ids" },
value: {
kind: "Variable",
name: { kind: "Name", value: "ids" },
},
},
],
selectionSet: {
kind: "SelectionSet",
selections: [
{ kind: "Field", name: { kind: "Name", value: "ids" } },
],
},
},
],
},
},
],
} as unknown as DocumentNode<ScenesUpdatesQuery, ScenesUpdatesQueryVariables>;
export const ScenesWithFingerprintsDocument = {
kind: "Document",
definitions: [
Expand Down
3 changes: 3 additions & 0 deletions graphql/schema/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ type Query {
findSite(id: ID!): Site @hasRole(role: READ)
querySites: QuerySitesResultType! @hasRole(role: READ)

"""Find scene updated time by ID"""
findScenesUpdates(ids: [ID!]!): QueryScenesUpdatesResult @hasRole(role: READ)

#### Edits ####

findEdit(id: ID!): Edit @hasRole(role: READ)
Expand Down
5 changes: 5 additions & 0 deletions graphql/schema/types/scene.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -288,3 +288,8 @@ type QueryExistingSceneResult {
edits: [Edit!]!
scenes: [Scene!]!
}

type QueryScenesUpdatesResult {
ids: [ID!]!
updated: [Time!]!
}
12 changes: 11 additions & 1 deletion pkg/api/resolver_query_find_scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package api
import (
"context"
"errors"

"github.com/gofrs/uuid"

"github.com/stashapp/stash-box/pkg/manager/config"
Expand Down Expand Up @@ -116,6 +115,17 @@ func (r *queryResolver) FindScenesBySceneFingerprints(ctx context.Context, scene
return result, nil
}

func (r *queryResolver) FindScenesUpdates(ctx context.Context, ids []uuid.UUID) (*models.QueryScenesUpdatesResult, error) {
if len(ids) > 100 {
return nil, errors.New("too many ids, request less than 100 ids")
}

fac := r.getRepoFactory(ctx)
qb := fac.Scene()

return qb.FindUpdatesByIds(ids)
}

type querySceneResolver struct{ *Resolver }

func (r *querySceneResolver) Count(ctx context.Context, obj *models.SceneQuery) (int, error) {
Expand Down
Loading

0 comments on commit b2d0a3d

Please sign in to comment.