mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Multiple scene URLs (#3852)
* Add URLs scene relationship * Update unit tests * Update scene edit and details pages * Update scrapers to use urls * Post-process scenes during query scrape * Update UI for URLs * Change urls label
This commit is contained in:
@@ -21,6 +21,12 @@ import (
|
||||
)
|
||||
|
||||
func loadSceneRelationships(ctx context.Context, expected models.Scene, actual *models.Scene) error {
|
||||
if expected.URLs.Loaded() {
|
||||
if err := actual.LoadURLs(ctx, db.Scene); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if expected.GalleryIDs.Loaded() {
|
||||
if err := actual.LoadGalleryIDs(ctx, db.Scene); err != nil {
|
||||
return err
|
||||
@@ -108,7 +114,7 @@ func Test_sceneQueryBuilder_Create(t *testing.T) {
|
||||
Code: code,
|
||||
Details: details,
|
||||
Director: director,
|
||||
URL: url,
|
||||
URLs: models.NewRelatedStrings([]string{url}),
|
||||
Date: &date,
|
||||
Rating: &rating,
|
||||
Organized: true,
|
||||
@@ -153,7 +159,7 @@ func Test_sceneQueryBuilder_Create(t *testing.T) {
|
||||
Code: code,
|
||||
Details: details,
|
||||
Director: director,
|
||||
URL: url,
|
||||
URLs: models.NewRelatedStrings([]string{url}),
|
||||
Date: &date,
|
||||
Rating: &rating,
|
||||
Organized: true,
|
||||
@@ -346,7 +352,7 @@ func Test_sceneQueryBuilder_Update(t *testing.T) {
|
||||
Code: code,
|
||||
Details: details,
|
||||
Director: director,
|
||||
URL: url,
|
||||
URLs: models.NewRelatedStrings([]string{url}),
|
||||
Date: &date,
|
||||
Rating: &rating,
|
||||
Organized: true,
|
||||
@@ -513,7 +519,7 @@ func clearScenePartial() models.ScenePartial {
|
||||
Code: models.OptionalString{Set: true, Null: true},
|
||||
Details: models.OptionalString{Set: true, Null: true},
|
||||
Director: models.OptionalString{Set: true, Null: true},
|
||||
URL: models.OptionalString{Set: true, Null: true},
|
||||
URLs: &models.UpdateStrings{Mode: models.RelationshipUpdateModeSet},
|
||||
Date: models.OptionalDate{Set: true, Null: true},
|
||||
Rating: models.OptionalInt{Set: true, Null: true},
|
||||
StudioID: models.OptionalInt{Set: true, Null: true},
|
||||
@@ -560,11 +566,14 @@ func Test_sceneQueryBuilder_UpdatePartial(t *testing.T) {
|
||||
"full",
|
||||
sceneIDs[sceneIdxWithSpacedName],
|
||||
models.ScenePartial{
|
||||
Title: models.NewOptionalString(title),
|
||||
Code: models.NewOptionalString(code),
|
||||
Details: models.NewOptionalString(details),
|
||||
Director: models.NewOptionalString(director),
|
||||
URL: models.NewOptionalString(url),
|
||||
Title: models.NewOptionalString(title),
|
||||
Code: models.NewOptionalString(code),
|
||||
Details: models.NewOptionalString(details),
|
||||
Director: models.NewOptionalString(director),
|
||||
URLs: &models.UpdateStrings{
|
||||
Values: []string{url},
|
||||
Mode: models.RelationshipUpdateModeSet,
|
||||
},
|
||||
Date: models.NewOptionalDate(date),
|
||||
Rating: models.NewOptionalInt(rating),
|
||||
Organized: models.NewOptionalBool(true),
|
||||
@@ -624,7 +633,7 @@ func Test_sceneQueryBuilder_UpdatePartial(t *testing.T) {
|
||||
Code: code,
|
||||
Details: details,
|
||||
Director: director,
|
||||
URL: url,
|
||||
URLs: models.NewRelatedStrings([]string{url}),
|
||||
Date: &date,
|
||||
Rating: &rating,
|
||||
Organized: true,
|
||||
@@ -2400,7 +2409,14 @@ func TestSceneQueryURL(t *testing.T) {
|
||||
|
||||
verifyFn := func(s *models.Scene) {
|
||||
t.Helper()
|
||||
verifyString(t, s.URL, urlCriterion)
|
||||
|
||||
urls := s.URLs.List()
|
||||
var url string
|
||||
if len(urls) > 0 {
|
||||
url = urls[0]
|
||||
}
|
||||
|
||||
verifyString(t, url, urlCriterion)
|
||||
}
|
||||
|
||||
verifySceneQuery(t, filter, verifyFn)
|
||||
@@ -2576,6 +2592,12 @@ func verifySceneQuery(t *testing.T, filter models.SceneFilterType, verifyFn func
|
||||
|
||||
scenes := queryScene(ctx, t, sqb, &filter, nil)
|
||||
|
||||
for _, scene := range scenes {
|
||||
if err := scene.LoadRelationships(ctx, sqb); err != nil {
|
||||
t.Errorf("Error loading scene relationships: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// assume it should find at least one
|
||||
assert.Greater(t, len(scenes), 0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user