mirror of
https://github.com/stashapp/stash.git
synced 2026-05-04 15:39:52 -05:00
[Feature] Add fields director and (studio) code to scenes (#3051)
* added schema migration and updated data models * added code and director to UI * new fields are exported and imported * added filters * Add changelog entry
This commit is contained in:
@@ -22,7 +22,7 @@ import (
|
||||
"github.com/stashapp/stash/pkg/logger"
|
||||
)
|
||||
|
||||
var appSchemaVersion uint = 37
|
||||
var appSchemaVersion uint = 38
|
||||
|
||||
//go:embed migrations/*.sql
|
||||
var migrationsBox embed.FS
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE `scenes` ADD COLUMN `code` text;
|
||||
ALTER TABLE `scenes` ADD COLUMN `director` text;
|
||||
@@ -54,7 +54,9 @@ ORDER BY files.size DESC
|
||||
type sceneRow struct {
|
||||
ID int `db:"id" goqu:"skipinsert"`
|
||||
Title zero.String `db:"title"`
|
||||
Code zero.String `db:"code"`
|
||||
Details zero.String `db:"details"`
|
||||
Director zero.String `db:"director"`
|
||||
URL zero.String `db:"url"`
|
||||
Date models.SQLiteDate `db:"date"`
|
||||
Rating null.Int `db:"rating"`
|
||||
@@ -68,7 +70,9 @@ type sceneRow struct {
|
||||
func (r *sceneRow) fromScene(o models.Scene) {
|
||||
r.ID = o.ID
|
||||
r.Title = zero.StringFrom(o.Title)
|
||||
r.Code = zero.StringFrom(o.Code)
|
||||
r.Details = zero.StringFrom(o.Details)
|
||||
r.Director = zero.StringFrom(o.Director)
|
||||
r.URL = zero.StringFrom(o.URL)
|
||||
if o.Date != nil {
|
||||
_ = r.Date.Scan(o.Date.Time)
|
||||
@@ -94,7 +98,9 @@ func (r *sceneQueryRow) resolve() *models.Scene {
|
||||
ret := &models.Scene{
|
||||
ID: r.ID,
|
||||
Title: r.Title.String,
|
||||
Code: r.Code.String,
|
||||
Details: r.Details.String,
|
||||
Director: r.Director.String,
|
||||
URL: r.URL.String,
|
||||
Date: r.Date.DatePtr(),
|
||||
Rating: nullIntPtr(r.Rating),
|
||||
@@ -123,7 +129,9 @@ type sceneRowRecord struct {
|
||||
|
||||
func (r *sceneRowRecord) fromPartial(o models.ScenePartial) {
|
||||
r.setNullString("title", o.Title)
|
||||
r.setNullString("code", o.Code)
|
||||
r.setNullString("details", o.Details)
|
||||
r.setNullString("director", o.Director)
|
||||
r.setNullString("url", o.URL)
|
||||
r.setSQLiteDate("date", o.Date)
|
||||
r.setNullInt("rating", o.Rating)
|
||||
@@ -801,7 +809,9 @@ func (qb *SceneStore) makeFilter(ctx context.Context, sceneFilter *models.SceneF
|
||||
query.handleCriterion(ctx, pathCriterionHandler(sceneFilter.Path, "folders.path", "files.basename", qb.addFoldersTable))
|
||||
query.handleCriterion(ctx, sceneFileCountCriterionHandler(qb, sceneFilter.FileCount))
|
||||
query.handleCriterion(ctx, stringCriterionHandler(sceneFilter.Title, "scenes.title"))
|
||||
query.handleCriterion(ctx, stringCriterionHandler(sceneFilter.Code, "scenes.code"))
|
||||
query.handleCriterion(ctx, stringCriterionHandler(sceneFilter.Details, "scenes.details"))
|
||||
query.handleCriterion(ctx, stringCriterionHandler(sceneFilter.Director, "scenes.director"))
|
||||
query.handleCriterion(ctx, criterionHandlerFunc(func(ctx context.Context, f *filterBuilder) {
|
||||
if sceneFilter.Oshash != nil {
|
||||
qb.addSceneFilesTable(f)
|
||||
|
||||
@@ -73,7 +73,9 @@ func loadSceneRelationships(ctx context.Context, expected models.Scene, actual *
|
||||
func Test_sceneQueryBuilder_Create(t *testing.T) {
|
||||
var (
|
||||
title = "title"
|
||||
code = "1337"
|
||||
details = "details"
|
||||
director = "director"
|
||||
url = "url"
|
||||
rating = 3
|
||||
ocounter = 5
|
||||
@@ -100,7 +102,9 @@ func Test_sceneQueryBuilder_Create(t *testing.T) {
|
||||
"full",
|
||||
models.Scene{
|
||||
Title: title,
|
||||
Code: code,
|
||||
Details: details,
|
||||
Director: director,
|
||||
URL: url,
|
||||
Date: &date,
|
||||
Rating: &rating,
|
||||
@@ -139,7 +143,9 @@ func Test_sceneQueryBuilder_Create(t *testing.T) {
|
||||
"with file",
|
||||
models.Scene{
|
||||
Title: title,
|
||||
Code: code,
|
||||
Details: details,
|
||||
Director: director,
|
||||
URL: url,
|
||||
Date: &date,
|
||||
Rating: &rating,
|
||||
@@ -294,7 +300,9 @@ func makeSceneFileWithID(i int) *file.VideoFile {
|
||||
func Test_sceneQueryBuilder_Update(t *testing.T) {
|
||||
var (
|
||||
title = "title"
|
||||
code = "1337"
|
||||
details = "details"
|
||||
director = "director"
|
||||
url = "url"
|
||||
rating = 3
|
||||
ocounter = 5
|
||||
@@ -320,7 +328,9 @@ func Test_sceneQueryBuilder_Update(t *testing.T) {
|
||||
&models.Scene{
|
||||
ID: sceneIDs[sceneIdxWithGallery],
|
||||
Title: title,
|
||||
Code: code,
|
||||
Details: details,
|
||||
Director: director,
|
||||
URL: url,
|
||||
Date: &date,
|
||||
Rating: &rating,
|
||||
@@ -481,7 +491,9 @@ func clearScenePartial() models.ScenePartial {
|
||||
// leave mandatory fields
|
||||
return models.ScenePartial{
|
||||
Title: models.OptionalString{Set: true, Null: true},
|
||||
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},
|
||||
Date: models.OptionalDate{Set: true, Null: true},
|
||||
Rating: models.OptionalInt{Set: true, Null: true},
|
||||
@@ -496,7 +508,9 @@ func clearScenePartial() models.ScenePartial {
|
||||
func Test_sceneQueryBuilder_UpdatePartial(t *testing.T) {
|
||||
var (
|
||||
title = "title"
|
||||
code = "1337"
|
||||
details = "details"
|
||||
director = "director"
|
||||
url = "url"
|
||||
rating = 3
|
||||
ocounter = 5
|
||||
@@ -524,7 +538,9 @@ func Test_sceneQueryBuilder_UpdatePartial(t *testing.T) {
|
||||
sceneIDs[sceneIdxWithSpacedName],
|
||||
models.ScenePartial{
|
||||
Title: models.NewOptionalString(title),
|
||||
Code: models.NewOptionalString(code),
|
||||
Details: models.NewOptionalString(details),
|
||||
Director: models.NewOptionalString(director),
|
||||
URL: models.NewOptionalString(url),
|
||||
Date: models.NewOptionalDate(date),
|
||||
Rating: models.NewOptionalInt(rating),
|
||||
@@ -578,7 +594,9 @@ func Test_sceneQueryBuilder_UpdatePartial(t *testing.T) {
|
||||
makeSceneFile(sceneIdxWithSpacedName),
|
||||
}),
|
||||
Title: title,
|
||||
Code: code,
|
||||
Details: details,
|
||||
Director: director,
|
||||
URL: url,
|
||||
Date: &date,
|
||||
Rating: &rating,
|
||||
|
||||
@@ -1403,7 +1403,7 @@ func getTagChildCount(id int) int {
|
||||
return 0
|
||||
}
|
||||
|
||||
//createTags creates n tags with plain Name and o tags with camel cased NaMe included
|
||||
// createTags creates n tags with plain Name and o tags with camel cased NaMe included
|
||||
func createTags(ctx context.Context, tqb models.TagReaderWriter, n int, o int) error {
|
||||
const namePlain = "Name"
|
||||
const nameNoCase = "NaMe"
|
||||
|
||||
Reference in New Issue
Block a user