Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scene filters save json #4520

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions graphql/documents/data/scene-slim.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ fragment SlimSceneData on Scene {
organized
interactive
interactive_speed
filters
resume_time
play_duration
play_count
Expand Down
1 change: 1 addition & 0 deletions graphql/documents/data/scene.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ fragment SceneData on Scene {
organized
interactive
interactive_speed
filters
captions {
language_code
caption_type
Expand Down
5 changes: 4 additions & 1 deletion graphql/schema/types/scene.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ type Scene {
play_duration: Float
"The number ot times a scene has been played"
play_count: Int
"Scene filters JSON data"
filters: String

files: [VideoFile!]!
paths: ScenePathsType! # Resolver
Expand Down Expand Up @@ -96,7 +98,7 @@ input SceneCreateInput {
"This should be a URL or a base64 encoded data URL"
cover_image: String
stash_ids: [StashIDInput!]

filters: String
"""
The first id will be assigned as primary.
Files will be reassigned from existing scenes if applicable.
Expand Down Expand Up @@ -127,6 +129,7 @@ input SceneUpdateInput {
"This should be a URL or a base64 encoded data URL"
cover_image: String
stash_ids: [StashIDInput!]
filters: String

"The time index a scene was left at"
resume_time: Float
Expand Down
2 changes: 2 additions & 0 deletions internal/api/resolver_mutation_scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func (r *mutationResolver) SceneCreate(ctx context.Context, input models.SceneCr
newScene.Rating = input.Rating100
newScene.Organized = translator.bool(input.Organized)
newScene.StashIDs = models.NewRelatedStashIDs(input.StashIds)
newScene.Filters = translator.string(input.Filters)

newScene.Date, err = translator.datePtr(input.Date)
if err != nil {
Expand Down Expand Up @@ -174,6 +175,7 @@ func scenePartialFromInput(input models.SceneUpdateInput, translator changesetTr
updatedScene.PlayDuration = translator.optionalFloat64(input.PlayDuration, "play_duration")
updatedScene.Organized = translator.optionalBool(input.Organized, "organized")
updatedScene.StashIDs = translator.updateStashIDs(input.StashIds, "stash_ids")
updatedScene.Filters = translator.optionalString(input.Filters, "filters")

var err error

Expand Down
1 change: 1 addition & 0 deletions pkg/models/jsonschema/scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ type Scene struct {
PlayCount int `json:"play_count,omitempty"`
PlayDuration float64 `json:"play_duration,omitempty"`
StashIDs []models.StashID `json:"stash_ids,omitempty"`
Filters string `json:"filters,omitempty"`
}

func (s Scene) Filename(id int, basename string, hash string) string {
Expand Down
2 changes: 2 additions & 0 deletions pkg/models/model_scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type Scene struct {
PerformerIDs RelatedIDs `json:"performer_ids"`
Movies RelatedMovies `json:"movies"`
StashIDs RelatedStashIDs `json:"stash_ids"`
Filters string `json:"filters"`
}

func NewScene() Scene {
Expand Down Expand Up @@ -75,6 +76,7 @@ type ScenePartial struct {
PlayDuration OptionalFloat64
PlayCount OptionalInt
LastPlayedAt OptionalTime
Filters OptionalString

URLs *UpdateStrings
GalleryIDs *UpdateIDs
Expand Down
4 changes: 4 additions & 0 deletions pkg/models/scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ type SceneFilterType struct {
CreatedAt *TimestampCriterionInput `json:"created_at"`
// Filter by updated at
UpdatedAt *TimestampCriterionInput `json:"updated_at"`
// Filter by scene filters
Filters *StringCriterionInput `json:"filters"`
}

type SceneQueryOptions struct {
Expand Down Expand Up @@ -138,6 +140,7 @@ type SceneCreateInput struct {
// This should be a URL or a base64 encoded data URL
CoverImage *string `json:"cover_image"`
StashIds []StashID `json:"stash_ids"`
Filters *string `json:"filters"`
// The first id will be assigned as primary.
// Files will be reassigned from existing scenes if applicable.
// Files must not already be primary for another scene.
Expand All @@ -162,6 +165,7 @@ type SceneUpdateInput struct {
PerformerIds []string `json:"performer_ids"`
Movies []SceneMovieInput `json:"movies"`
TagIds []string `json:"tag_ids"`
Filters *string `json:"filters"`
// This should be a URL or a base64 encoded data URL
CoverImage *string `json:"cover_image"`
StashIds []StashID `json:"stash_ids"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/sqlite/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const (
dbConnTimeout = 30
)

var appSchemaVersion uint = 54
var appSchemaVersion uint = 55

//go:embed migrations/*.sql
var migrationsBox embed.FS
Expand Down
2 changes: 2 additions & 0 deletions pkg/sqlite/migrations/55_scene_filters.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE scenes
ADD COLUMN filters text;
5 changes: 5 additions & 0 deletions pkg/sqlite/scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ type sceneRow struct {
ResumeTime float64 `db:"resume_time"`
PlayDuration float64 `db:"play_duration"`
PlayCount int `db:"play_count"`
Filters zero.String `db:"filters"`

// not used in resolutions or updates
CoverBlob zero.String `db:"cover_blob"`
Expand All @@ -111,6 +112,7 @@ func (r *sceneRow) fromScene(o models.Scene) {
r.ResumeTime = o.ResumeTime
r.PlayDuration = o.PlayDuration
r.PlayCount = o.PlayCount
r.Filters = zero.StringFrom(o.Filters)
}

type sceneQueryRow struct {
Expand Down Expand Up @@ -146,6 +148,7 @@ func (r *sceneQueryRow) resolve() *models.Scene {
ResumeTime: r.ResumeTime,
PlayDuration: r.PlayDuration,
PlayCount: r.PlayCount,
Filters: r.Filters.String,
}

if r.PrimaryFileFolderPath.Valid && r.PrimaryFileBasename.Valid {
Expand Down Expand Up @@ -175,6 +178,7 @@ func (r *sceneRowRecord) fromPartial(o models.ScenePartial) {
r.setFloat64("resume_time", o.ResumeTime)
r.setFloat64("play_duration", o.PlayDuration)
r.setInt("play_count", o.PlayCount)
r.setNullString("filters", o.Filters)
}

type SceneStore struct {
Expand Down Expand Up @@ -1012,6 +1016,7 @@ func (qb *SceneStore) makeFilter(ctx context.Context, sceneFilter *models.SceneF
query.handleCriterion(ctx, floatIntCriterionHandler(sceneFilter.ResumeTime, "scenes.resume_time", nil))
query.handleCriterion(ctx, floatIntCriterionHandler(sceneFilter.PlayDuration, "scenes.play_duration", nil))
query.handleCriterion(ctx, intCriterionHandler(sceneFilter.PlayCount, "scenes.play_count", nil))
query.handleCriterion(ctx, stringCriterionHandler(sceneFilter.Filters, "scenes.filters"))

query.handleCriterion(ctx, sceneTagsCriterionHandler(qb, sceneFilter.Tags))
query.handleCriterion(ctx, sceneTagCountCriterionHandler(qb, sceneFilter.TagCount))
Expand Down
11 changes: 9 additions & 2 deletions ui/v2.5/src/components/Scenes/SceneDetails/Scene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ const SceneVideoFilterPanel = lazyComponent(
import { objectPath, objectTitle } from "src/core/files";

interface IProps {
scene: GQL.SceneDataFragment;
scene: GQL.SceneDataFragment & {
filters?: string | null | undefined;
};
setTimestamp: (num: number) => void;
queueScenes: QueuedScene[];
onQueueNext: () => void;
Expand Down Expand Up @@ -157,6 +159,7 @@ const ScenePage: React.FC<IProps> = ({
Mousetrap.bind("q", () => setActiveTabKey("scene-queue-panel"));
Mousetrap.bind("e", () => setActiveTabKey("scene-edit-panel"));
Mousetrap.bind("k", () => setActiveTabKey("scene-markers-panel"));
Mousetrap.bind("f", () => setActiveTabKey("scene-video-filter-panel"));
Mousetrap.bind("i", () => setActiveTabKey("scene-file-info-panel"));
Mousetrap.bind("o", () => {
onIncrementClick();
Expand All @@ -171,6 +174,7 @@ const ScenePage: React.FC<IProps> = ({
Mousetrap.unbind("q");
Mousetrap.unbind("e");
Mousetrap.unbind("k");
Mousetrap.unbind("f");
Mousetrap.unbind("i");
Mousetrap.unbind("o");
Mousetrap.unbind("p n");
Expand Down Expand Up @@ -474,7 +478,10 @@ const ScenePage: React.FC<IProps> = ({
</Tab.Pane>
)}
<Tab.Pane eventKey="scene-video-filter-panel">
<SceneVideoFilterPanel scene={scene} />
<SceneVideoFilterPanel
scene={scene}
isVisible={activeTabKey === "scene-filters-panel"}
/>
</Tab.Pane>
<Tab.Pane className="file-info-panel" eventKey="scene-file-info-panel">
<SceneFileInfoPanel scene={scene} />
Expand Down
Loading
Loading