mirror of
https://github.com/stashapp/stash.git
synced 2025-12-16 20:07:05 +03:00
Markers can have end time (#5311)
* Markers can have end time Other metadata sources such as ThePornDB and timestamp.trade support end times for markers but Stash did not yet support saving those. This is a first step which only allows end time to be set either via API or via UI. Other aspects of Stash such as video player timeline are not yet updated to take end time into account. - User can set end time when creating or editing markers in the UI or in the API. - End time cannot be before start time. This is validated in the backend and for better UX also in the frontend. - End time is shown in scene details view or markers wall view if present. - GraphQL API does not require end_seconds. --------- Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
@@ -8,6 +8,7 @@ type SceneMarker struct {
|
||||
ID int `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Seconds float64 `json:"seconds"`
|
||||
EndSeconds *float64 `json:"end_seconds"`
|
||||
PrimaryTagID int `json:"primary_tag_id"`
|
||||
SceneID int `json:"scene_id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
@@ -27,6 +28,7 @@ func NewSceneMarker() SceneMarker {
|
||||
type SceneMarkerPartial struct {
|
||||
Title OptionalString
|
||||
Seconds OptionalFloat64
|
||||
EndSeconds OptionalFloat64
|
||||
PrimaryTagID OptionalInt
|
||||
SceneID OptionalInt
|
||||
CreatedAt OptionalTime
|
||||
|
||||
@@ -34,7 +34,7 @@ const (
|
||||
cacheSizeEnv = "STASH_SQLITE_CACHE_SIZE"
|
||||
)
|
||||
|
||||
var appSchemaVersion uint = 69
|
||||
var appSchemaVersion uint = 70
|
||||
|
||||
//go:embed migrations/*.sql
|
||||
var migrationsBox embed.FS
|
||||
|
||||
1
pkg/sqlite/migrations/70_markers_end.up.sql
Normal file
1
pkg/sqlite/migrations/70_markers_end.up.sql
Normal file
@@ -0,0 +1 @@
|
||||
ALTER TABLE scene_markers ADD COLUMN end_seconds FLOAT;
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/doug-martin/goqu/v9"
|
||||
"github.com/doug-martin/goqu/v9/exp"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"gopkg.in/guregu/null.v4"
|
||||
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
)
|
||||
@@ -24,19 +25,23 @@ GROUP BY scene_markers.id
|
||||
`
|
||||
|
||||
type sceneMarkerRow struct {
|
||||
ID int `db:"id" goqu:"skipinsert"`
|
||||
Title string `db:"title"` // TODO: make db schema (and gql schema) nullable
|
||||
Seconds float64 `db:"seconds"`
|
||||
PrimaryTagID int `db:"primary_tag_id"`
|
||||
SceneID int `db:"scene_id"`
|
||||
CreatedAt Timestamp `db:"created_at"`
|
||||
UpdatedAt Timestamp `db:"updated_at"`
|
||||
ID int `db:"id" goqu:"skipinsert"`
|
||||
Title string `db:"title"` // TODO: make db schema (and gql schema) nullable
|
||||
Seconds float64 `db:"seconds"`
|
||||
PrimaryTagID int `db:"primary_tag_id"`
|
||||
SceneID int `db:"scene_id"`
|
||||
CreatedAt Timestamp `db:"created_at"`
|
||||
UpdatedAt Timestamp `db:"updated_at"`
|
||||
EndSeconds null.Float `db:"end_seconds"`
|
||||
}
|
||||
|
||||
func (r *sceneMarkerRow) fromSceneMarker(o models.SceneMarker) {
|
||||
r.ID = o.ID
|
||||
r.Title = o.Title
|
||||
r.Seconds = o.Seconds
|
||||
if o.EndSeconds != nil {
|
||||
r.EndSeconds = null.FloatFrom(*o.EndSeconds)
|
||||
}
|
||||
r.PrimaryTagID = o.PrimaryTagID
|
||||
r.SceneID = o.SceneID
|
||||
r.CreatedAt = Timestamp{Timestamp: o.CreatedAt}
|
||||
@@ -48,6 +53,7 @@ func (r *sceneMarkerRow) resolve() *models.SceneMarker {
|
||||
ID: r.ID,
|
||||
Title: r.Title,
|
||||
Seconds: r.Seconds,
|
||||
EndSeconds: r.EndSeconds.Ptr(),
|
||||
PrimaryTagID: r.PrimaryTagID,
|
||||
SceneID: r.SceneID,
|
||||
CreatedAt: r.CreatedAt.Timestamp,
|
||||
@@ -69,6 +75,7 @@ func (r *sceneMarkerRowRecord) fromPartial(o models.SceneMarkerPartial) {
|
||||
r.set("title", o.Title.Value)
|
||||
}
|
||||
r.setFloat64("seconds", o.Seconds)
|
||||
r.setNullFloat64("end_seconds", o.EndSeconds)
|
||||
r.setInt("primary_tag_id", o.PrimaryTagID)
|
||||
r.setInt("scene_id", o.SceneID)
|
||||
r.setTimestamp("created_at", o.CreatedAt)
|
||||
|
||||
Reference in New Issue
Block a user