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 play and o-counter history view and editing #4532

Merged
merged 60 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
bc18bdc
Added History Panel and Play Counter
randemgame Jun 18, 2023
aceaabd
Migration to add the tables scenes_odates and scenes_playdates and po…
randemgame Jun 20, 2023
fb1ba33
Recording dates to the SQL when using the PlayCounter/OCounter
randemgame Jun 22, 2023
6a843df
Merge branch 'stashapp:develop' into manual-history
randemgame Jun 22, 2023
86107ba
Merge branch 'stashapp:develop' into manual-history
randemgame Jun 23, 2023
78b79dc
Fixing Translation Errors & Including History Panel
randemgame Jun 23, 2023
29525e6
Fixing React Error re 'Function Components Cannot Be Given Refs' and …
randemgame Jun 23, 2023
ecc1244
fix for delete most recent play/o
randemgame Jun 23, 2023
e320584
Fixed Time Format & Building History Panel
randemgame Jun 23, 2023
54ef852
Consolidating all Date Information to History Panel
randemgame Jun 24, 2023
ab3d0d0
removing unused functions
randemgame Jul 9, 2023
2a6783b
Squashed commit of the following:
randemgame Jul 12, 2023
76576d9
Updated DB version and moved a function
randemgame Jul 12, 2023
219c3f2
Revert "Updated DB version and moved a function"
randemgame Jul 12, 2023
73bb45b
Revert "Squashed commit of the following:"
randemgame Jul 12, 2023
b60da30
Merge remote-tracking branch 'upstream/develop' into manual-history
randemgame Jul 12, 2023
f5c470e
Updated DB Version and moved a function
randemgame Jul 12, 2023
0a838a4
TEMP added ResetWatchCount and DecrementWatchCount in scene_test.go
randemgame Jul 12, 2023
505748a
fixes to pass validate check
randemgame Jul 13, 2023
0432372
Merge branch 'stashapp:develop' into manual-history
randemgame Jul 14, 2023
f04d55b
Updated DB number & fmt
randemgame Jul 14, 2023
00e5ede
added bool isScene check for Increment/Decrement/Reset O counter
randemgame Jul 15, 2023
f0a2fc2
Updated migrations file
randemgame Jul 15, 2023
5764e07
moved PlayDate/Counter structs and funcs back to scene.go
randemgame Jul 15, 2023
5dd1e33
removed unnecessary code
randemgame Jul 15, 2023
637b253
Expanding the Play & O Date Displays
randemgame Jul 15, 2023
ec49617
swapped hardcoded text
randemgame Jul 16, 2023
378fc70
split Increment/Decrement/ResetOCounter from Image and Scene
randemgame Jul 16, 2023
5da1810
cleanup for pull request
randemgame Jul 17, 2023
20d6f5e
Merge remote-tracking branch 'upstream/develop' into manual-history
randemgame Sep 27, 2023
7ccee3e
fixes for merge
randemgame Sep 27, 2023
a374214
rewriting history
randemgame Sep 28, 2023
606afc1
formatting
randemgame Sep 28, 2023
33bdce8
Update en-GB.json
randemgame Sep 28, 2023
3527408
First Working Date Retrieval
randemgame Oct 2, 2023
3f27e87
Sort Displayed Dates by existing "id" column not "position"
randemgame Oct 3, 2023
3a2376c
Merge remote-tracking branch 'upstream/develop' into prs/3922
WithoutPants Feb 6, 2024
a2f1d60
Refactor graphql schema
WithoutPants Feb 7, 2024
64ce245
Refactor backend code
WithoutPants Feb 7, 2024
b18269a
Fix last played format
WithoutPants Feb 7, 2024
dc15d4f
Add dataloaders
WithoutPants Feb 7, 2024
4a55fe2
Refactor history panel
WithoutPants Feb 7, 2024
6983018
Add buttons and improve layout
WithoutPants Feb 7, 2024
3d7e20c
Integrate functionality
WithoutPants Feb 8, 2024
0c3520e
Fix manual date issues
WithoutPants Feb 8, 2024
2297e77
Remove play counter button for now
WithoutPants Feb 8, 2024
7b54cc0
Fix deleting scenes
WithoutPants Feb 8, 2024
9fe9b52
Support multiple dates and fix merge
WithoutPants Feb 8, 2024
33035ac
Cleanup
WithoutPants Feb 8, 2024
508dd07
Fix performer o-counter sorting
WithoutPants Feb 8, 2024
ad42936
Fix performer o-counter filtering
WithoutPants Feb 8, 2024
2cc224a
Allow for null last_played_at
WithoutPants Feb 10, 2024
b10a3da
Redesign api to return updated history
WithoutPants Feb 12, 2024
2329acd
Fix scene merge
WithoutPants Feb 12, 2024
32db582
Merge remote-tracking branch 'upstream/develop' into scene-play-history
WithoutPants Feb 16, 2024
8bb422d
Replace count functions
WithoutPants Feb 16, 2024
8896151
Add unit tests
WithoutPants Feb 16, 2024
7208d9e
Render auto-filled dates as unknown
WithoutPants Feb 16, 2024
5c9db94
Merge remote-tracking branch 'upstream/develop' into scene-play-history
WithoutPants Feb 21, 2024
d7c8854
Use UTC timestamps
WithoutPants Feb 21, 2024
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
18 changes: 16 additions & 2 deletions graphql/schema/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,15 @@ type Mutation {
scenesUpdate(input: [SceneUpdateInput!]!): [Scene]

"Increments the o-counter for a scene. Returns the new value"
sceneIncrementO(id: ID!): Int!
sceneIncrementO(id: ID!): Int! @deprecated(reason: "Use sceneAddO instead")
"Decrements the o-counter for a scene. Returns the new value"
sceneDecrementO(id: ID!): Int!
sceneDecrementO(id: ID!): Int! @deprecated(reason: "Use sceneRemoveO instead")

"Increments the o-counter for a scene. Uses the current time if none provided."
sceneAddO(id: ID!, times: [Timestamp!]): HistoryMutationResult!
"Decrements the o-counter for a scene, removing the last recorded time if specific time not provided. Returns the new value"
sceneDeleteO(id: ID!, times: [Timestamp!]): HistoryMutationResult!

"Resets the o-counter for a scene to 0. Returns the new value"
sceneResetO(id: ID!): Int!

Expand All @@ -248,6 +254,14 @@ type Mutation {

"Increments the play count for the scene. Returns the new play count value."
sceneIncrementPlayCount(id: ID!): Int!
@deprecated(reason: "Use sceneAddPlay instead")

"Increments the play count for the scene. Uses the current time if none provided."
sceneAddPlay(id: ID!, times: [Timestamp!]): HistoryMutationResult!
"Decrements the play count for the scene, removing the specific times or the last recorded time if not provided."
sceneDeletePlay(id: ID!, times: [Timestamp!]): HistoryMutationResult!
"Resets the play count for a scene to 0. Returns the new play count value."
sceneResetPlayCount(id: ID!): Int!

"Generates screenshot at specified time in seconds. Leave empty to generate default screenshot"
sceneGenerateScreenshot(id: ID!, at: Float): String!
Expand Down
18 changes: 18 additions & 0 deletions graphql/schema/types/scene.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ type Scene {
"The number ot times a scene has been played"
play_count: Int

"Times a scene was played"
play_history: [Time!]!
"Times the o counter was incremented"
o_history: [Time!]!

files: [VideoFile!]!
paths: ScenePathsType! # Resolver
scene_markers: [SceneMarker!]!
Expand Down Expand Up @@ -118,6 +123,7 @@ input SceneUpdateInput {
# rating expressed as 1-100
rating100: Int
o_counter: Int
@deprecated(reason: "Unsupported - Use sceneIncrementO/sceneDecrementO")
organized: Boolean
studio_id: ID
gallery_ids: [ID!]
Expand All @@ -134,6 +140,9 @@ input SceneUpdateInput {
play_duration: Float
"The number ot times a scene has been played"
play_count: Int
@deprecated(
reason: "Unsupported - Use sceneIncrementPlayCount/sceneDecrementPlayCount"
)

primary_file_id: ID
}
Expand Down Expand Up @@ -251,4 +260,13 @@ input SceneMergeInput {
destination: ID!
# values defined here will override values in the destination
values: SceneUpdateInput

# if true, the source history will be combined with the destination
play_history: Boolean
o_history: Boolean
}

type HistoryMutationResult {
count: Int!
history: [Time!]!
}
96 changes: 93 additions & 3 deletions internal/api/loaders/dataloaders.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
//go:generate go run github.com/vektah/dataloaden SceneFileIDsLoader int []github.com/stashapp/stash/pkg/models.FileID
//go:generate go run github.com/vektah/dataloaden ImageFileIDsLoader int []github.com/stashapp/stash/pkg/models.FileID
//go:generate go run github.com/vektah/dataloaden GalleryFileIDsLoader int []github.com/stashapp/stash/pkg/models.FileID

//go:generate go run github.com/vektah/dataloaden SceneOCountLoader int int
//go:generate go run github.com/vektah/dataloaden ScenePlayCountLoader int int
//go:generate go run github.com/vektah/dataloaden SceneOHistoryLoader int []time.Time
//go:generate go run github.com/vektah/dataloaden ScenePlayHistoryLoader int []time.Time
//go:generate go run github.com/vektah/dataloaden SceneLastPlayedLoader int *time.Time
package loaders

import (
Expand All @@ -32,8 +36,14 @@ const (
)

type Loaders struct {
SceneByID *SceneLoader
SceneFiles *SceneFileIDsLoader
SceneByID *SceneLoader
SceneFiles *SceneFileIDsLoader
ScenePlayCount *ScenePlayCountLoader
SceneOCount *SceneOCountLoader
ScenePlayHistory *ScenePlayHistoryLoader
SceneOHistory *SceneOHistoryLoader
SceneLastPlayed *SceneLastPlayedLoader

ImageFiles *ImageFileIDsLoader
GalleryFiles *GalleryFileIDsLoader

Expand Down Expand Up @@ -109,6 +119,31 @@ func (m Middleware) Middleware(next http.Handler) http.Handler {
maxBatch: maxBatch,
fetch: m.fetchGalleriesFileIDs(ctx),
},
ScenePlayCount: &ScenePlayCountLoader{
wait: wait,
maxBatch: maxBatch,
fetch: m.fetchScenesPlayCount(ctx),
},
SceneOCount: &SceneOCountLoader{
wait: wait,
maxBatch: maxBatch,
fetch: m.fetchScenesOCount(ctx),
},
ScenePlayHistory: &ScenePlayHistoryLoader{
wait: wait,
maxBatch: maxBatch,
fetch: m.fetchScenesPlayHistory(ctx),
},
SceneLastPlayed: &SceneLastPlayedLoader{
wait: wait,
maxBatch: maxBatch,
fetch: m.fetchScenesLastPlayed(ctx),
},
SceneOHistory: &SceneOHistoryLoader{
wait: wait,
maxBatch: maxBatch,
fetch: m.fetchScenesOHistory(ctx),
},
}

newCtx := context.WithValue(r.Context(), loadersCtxKey, ldrs)
Expand Down Expand Up @@ -251,3 +286,58 @@ func (m Middleware) fetchGalleriesFileIDs(ctx context.Context) func(keys []int)
return ret, toErrorSlice(err)
}
}

func (m Middleware) fetchScenesOCount(ctx context.Context) func(keys []int) ([]int, []error) {
return func(keys []int) (ret []int, errs []error) {
err := m.Repository.WithDB(ctx, func(ctx context.Context) error {
var err error
ret, err = m.Repository.Scene.GetManyOCount(ctx, keys)
return err
})
return ret, toErrorSlice(err)
}
}

func (m Middleware) fetchScenesPlayCount(ctx context.Context) func(keys []int) ([]int, []error) {
return func(keys []int) (ret []int, errs []error) {
err := m.Repository.WithDB(ctx, func(ctx context.Context) error {
var err error
ret, err = m.Repository.Scene.GetManyViewCount(ctx, keys)
return err
})
return ret, toErrorSlice(err)
}
}

func (m Middleware) fetchScenesOHistory(ctx context.Context) func(keys []int) ([][]time.Time, []error) {
return func(keys []int) (ret [][]time.Time, errs []error) {
err := m.Repository.WithDB(ctx, func(ctx context.Context) error {
var err error
ret, err = m.Repository.Scene.GetManyODates(ctx, keys)
return err
})
return ret, toErrorSlice(err)
}
}

func (m Middleware) fetchScenesPlayHistory(ctx context.Context) func(keys []int) ([][]time.Time, []error) {
return func(keys []int) (ret [][]time.Time, errs []error) {
err := m.Repository.WithDB(ctx, func(ctx context.Context) error {
var err error
ret, err = m.Repository.Scene.GetManyViewDates(ctx, keys)
return err
})
return ret, toErrorSlice(err)
}
}

func (m Middleware) fetchScenesLastPlayed(ctx context.Context) func(keys []int) ([]*time.Time, []error) {
return func(keys []int) (ret []*time.Time, errs []error) {
err := m.Repository.WithDB(ctx, func(ctx context.Context) error {
var err error
ret, err = m.Repository.Scene.GetManyLastViewed(ctx, keys)
return err
})
return ret, toErrorSlice(err)
}
}
Loading
Loading