Skip to content

Commit

Permalink
Remove deprecated scene fields
Browse files Browse the repository at this point in the history
  • Loading branch information
WithoutPants committed Oct 16, 2023
1 parent 2c6e030 commit 2d9b973
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 84 deletions.
1 change: 0 additions & 1 deletion graphql/documents/data/movie.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@ fragment MovieData on Movie {
scenes {
id
title
path
}
}
16 changes: 1 addition & 15 deletions graphql/schema/types/scene.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ type ScenePathsType {
stream: String # Resolver
webp: String # Resolver
vtt: String # Resolver
chapters_vtt: String @deprecated
sprite: String # Resolver
funscript: String # Resolver
interactive_heatmap: String # Resolver
Expand All @@ -34,29 +33,23 @@ type VideoCaption {

type Scene {
id: ID!
checksum: String @deprecated(reason: "Use files.fingerprints")
oshash: String @deprecated(reason: "Use files.fingerprints")
title: String
code: String
details: String
director: String
url: String @deprecated(reason: "Use urls")
urls: [String!]!
date: String
# rating expressed as 1-5
rating: Int @deprecated(reason: "Use 1-100 range with rating100")
# rating expressed as 1-100
rating100: Int
organized: Boolean!
o_counter: Int
path: String! @deprecated(reason: "Use files.path")
phash: String @deprecated(reason: "Use files.fingerprints")
interactive: Boolean!
interactive_speed: Int
captions: [VideoCaption!]
created_at: Time!
updated_at: Time!
file_mod_time: Time
file_mod_time: Time @deprecated(reason: "Use files.mod_time")
"The last time play count was updated"
last_played_at: Time
"The time index a scene was left at"
Expand All @@ -66,7 +59,6 @@ type Scene {
"The number ot times a scene has been played"
play_count: Int

file: SceneFileType! @deprecated(reason: "Use files")
files: [VideoFile!]!
paths: ScenePathsType! # Resolver
scene_markers: [SceneMarker!]!
Expand Down Expand Up @@ -94,8 +86,6 @@ input SceneCreateInput {
url: String @deprecated(reason: "Use urls")
urls: [String!]
date: String
# rating expressed as 1-5
rating: Int @deprecated(reason: "Use 1-100 range with rating100")
# rating expressed as 1-100
rating100: Int
organized: Boolean
Expand Down Expand Up @@ -126,8 +116,6 @@ input SceneUpdateInput {
url: String @deprecated(reason: "Use urls")
urls: [String!]
date: String
# rating expressed as 1-5
rating: Int @deprecated(reason: "Use 1-100 range with rating100")
# rating expressed as 1-100
rating100: Int
o_counter: Int
Expand Down Expand Up @@ -172,8 +160,6 @@ input BulkSceneUpdateInput {
url: String @deprecated(reason: "Use urls")
urls: BulkUpdateStrings
date: String
# rating expressed as 1-5
rating: Int @deprecated(reason: "Use 1-100 range with rating100")
# rating expressed as 1-100
rating100: Int
organized: Boolean
Expand Down
53 changes: 0 additions & 53 deletions internal/api/resolver_model_scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ package api
import (
"context"
"fmt"
"strconv"
"time"

"github.com/stashapp/stash/internal/api/loaders"
"github.com/stashapp/stash/internal/api/urlbuilders"
"github.com/stashapp/stash/internal/manager"
"github.com/stashapp/stash/pkg/models"
"github.com/stashapp/stash/pkg/utils"
)

func convertVideoFile(f models.File) (*models.VideoFile, error) {
Expand Down Expand Up @@ -88,31 +86,6 @@ func (r *sceneResolver) Date(ctx context.Context, obj *models.Scene) (*string, e
return nil, nil
}

// File is deprecated
func (r *sceneResolver) File(ctx context.Context, obj *models.Scene) (*models.SceneFileType, error) {
f, err := r.getPrimaryFile(ctx, obj)
if err != nil {
return nil, err
}
if f == nil {
return nil, nil
}

bitrate := int(f.BitRate)
size := strconv.FormatInt(f.Size, 10)

return &models.SceneFileType{
Size: &size,
Duration: handleFloat64(f.Duration),
VideoCodec: &f.VideoCodec,
AudioCodec: &f.AudioCodec,
Width: &f.Width,
Height: &f.Height,
Framerate: handleFloat64(f.FrameRate),
Bitrate: &bitrate,
}, nil
}

func (r *sceneResolver) Files(ctx context.Context, obj *models.Scene) ([]*models.VideoFile, error) {
files, err := r.getFiles(ctx, obj)
if err != nil {
Expand Down Expand Up @@ -145,7 +118,6 @@ func (r *sceneResolver) Paths(ctx context.Context, obj *models.Scene) (*ScenePat
objHash := obj.GetHash(config.GetVideoFileNamingAlgorithm())
vttPath := builder.GetSpriteVTTURL(objHash)
spritePath := builder.GetSpriteURL(objHash)
chaptersVttPath := builder.GetChaptersVTTURL()
funscriptPath := builder.GetFunscriptURL()
captionBasePath := builder.GetCaptionURL()
interactiveHeatmap := builder.GetInteractiveHeatmapURL()
Expand All @@ -156,7 +128,6 @@ func (r *sceneResolver) Paths(ctx context.Context, obj *models.Scene) (*ScenePat
Stream: &streamPath,
Webp: &webpPath,
Vtt: &vttPath,
ChaptersVtt: &chaptersVttPath,
Sprite: &spritePath,
Funscript: &funscriptPath,
InteractiveHeatmap: &interactiveHeatmap,
Expand Down Expand Up @@ -285,30 +256,6 @@ func (r *sceneResolver) StashIds(ctx context.Context, obj *models.Scene) (ret []
return stashIDsSliceToPtrSlice(obj.StashIDs.List()), nil
}

func (r *sceneResolver) Phash(ctx context.Context, obj *models.Scene) (*string, error) {
f, err := r.getPrimaryFile(ctx, obj)
if err != nil {
return nil, err
}

if f == nil {
return nil, nil
}

val := f.Fingerprints.Get(models.FingerprintTypePhash)
if val == nil {
return nil, nil
}

phash, _ := val.(int64)

if phash != 0 {
hexval := utils.PhashToString(phash)
return &hexval, nil
}
return nil, nil
}

func (r *sceneResolver) SceneStreams(ctx context.Context, obj *models.Scene) ([]*manager.SceneStreamEndpoint, error) {
// load the primary file into the scene
_, err := r.getPrimaryFile(ctx, obj)
Expand Down
6 changes: 3 additions & 3 deletions internal/api/resolver_mutation_scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (r *mutationResolver) SceneCreate(ctx context.Context, input models.SceneCr
newScene.Code = translator.string(input.Code)
newScene.Details = translator.string(input.Details)
newScene.Director = translator.string(input.Director)
newScene.Rating = translator.ratingConversion(input.Rating, input.Rating100)
newScene.Rating = input.Rating100
newScene.Organized = translator.bool(input.Organized)
newScene.StashIDs = models.NewRelatedStashIDs(input.StashIds)

Expand Down Expand Up @@ -168,7 +168,7 @@ func scenePartialFromInput(input models.SceneUpdateInput, translator changesetTr
updatedScene.Code = translator.optionalString(input.Code, "code")
updatedScene.Details = translator.optionalString(input.Details, "details")
updatedScene.Director = translator.optionalString(input.Director, "director")
updatedScene.Rating = translator.optionalRatingConversion(input.Rating, input.Rating100)
updatedScene.Rating = translator.optionalInt(input.Rating100, "rating100")
updatedScene.OCounter = translator.optionalInt(input.OCounter, "o_counter")
updatedScene.PlayCount = translator.optionalInt(input.PlayCount, "play_count")
updatedScene.PlayDuration = translator.optionalFloat64(input.PlayDuration, "play_duration")
Expand Down Expand Up @@ -321,7 +321,7 @@ func (r *mutationResolver) BulkSceneUpdate(ctx context.Context, input BulkSceneU
updatedScene.Code = translator.optionalString(input.Code, "code")
updatedScene.Details = translator.optionalString(input.Details, "details")
updatedScene.Director = translator.optionalString(input.Director, "director")
updatedScene.Rating = translator.optionalRatingConversion(input.Rating, input.Rating100)
updatedScene.Rating = translator.optionalInt(input.Rating100, "rating100")
updatedScene.Organized = translator.optionalBool(input.Organized, "organized")

updatedScene.Date, err = translator.optionalDate(input.Date, "date")
Expand Down
4 changes: 0 additions & 4 deletions internal/api/urlbuilders/scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ func (b SceneURLBuilder) GetScreenshotURL() string {
return b.BaseURL + "/scene/" + b.SceneID + "/screenshot?t=" + b.UpdatedAt
}

func (b SceneURLBuilder) GetChaptersVTTURL() string {
return b.BaseURL + "/scene/" + b.SceneID + "/vtt/chapter"
}

func (b SceneURLBuilder) GetFunscriptURL() string {
return b.BaseURL + "/scene/" + b.SceneID + "/funscript"
}
Expand Down
6 changes: 0 additions & 6 deletions pkg/models/model_scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,6 @@ func (s ScenePartial) UpdateInput(id int) SceneUpdateInput {
StashIds: stashIDs,
}

if s.Rating.Set && !s.Rating.Null {
// convert to 1-100 scale
rating := Rating100To5(s.Rating.Value)
ret.Rating = &rating
}

return ret
}

Expand Down
2 changes: 0 additions & 2 deletions pkg/models/scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ type SceneCreateInput struct {
URL *string `json:"url"`
Urls []string `json:"urls"`
Date *string `json:"date"`
Rating *int `json:"rating"`
Rating100 *int `json:"rating100"`
Organized *bool `json:"organized"`
StudioID *string `json:"studio_id"`
Expand All @@ -155,7 +154,6 @@ type SceneUpdateInput struct {
URL *string `json:"url"`
Urls []string `json:"urls"`
Date *string `json:"date"`
Rating *int `json:"rating"`
Rating100 *int `json:"rating100"`
OCounter *int `json:"o_counter"`
Organized *bool `json:"organized"`
Expand Down

0 comments on commit 2d9b973

Please sign in to comment.