mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
added details, deathdate, hair color, weight to performers and added details to studios (#1274)
* added details to performers and studios * added deathdate, hair_color and weight to performers * Simplify performer/studio create mutations * Add changelog and recategorised Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
@@ -23,6 +23,10 @@ func ToJSON(reader models.StudioReader, studio *models.Studio) (*jsonschema.Stud
|
||||
newStudioJSON.URL = studio.URL.String
|
||||
}
|
||||
|
||||
if studio.Details.Valid {
|
||||
newStudioJSON.Details = studio.Details.String
|
||||
}
|
||||
|
||||
if studio.ParentID.Valid {
|
||||
parent, err := reader.Find(int(studio.ParentID.Int64))
|
||||
if err != nil {
|
||||
|
||||
@@ -24,10 +24,13 @@ const (
|
||||
errParentStudioID = 12
|
||||
)
|
||||
|
||||
const studioName = "testStudio"
|
||||
const url = "url"
|
||||
const (
|
||||
studioName = "testStudio"
|
||||
url = "url"
|
||||
details = "details"
|
||||
|
||||
const parentStudioName = "parentStudio"
|
||||
parentStudioName = "parentStudio"
|
||||
)
|
||||
|
||||
var parentStudio models.Studio = models.Studio{
|
||||
Name: models.NullString(parentStudioName),
|
||||
@@ -37,15 +40,15 @@ var imageBytes = []byte("imageBytes")
|
||||
|
||||
const image = "aW1hZ2VCeXRlcw=="
|
||||
|
||||
var createTime time.Time = time.Date(2001, 01, 01, 0, 0, 0, 0, time.UTC)
|
||||
var updateTime time.Time = time.Date(2002, 01, 01, 0, 0, 0, 0, time.UTC)
|
||||
var createTime time.Time = time.Date(2001, 01, 01, 0, 0, 0, 0, time.Local)
|
||||
var updateTime time.Time = time.Date(2002, 01, 01, 0, 0, 0, 0, time.Local)
|
||||
|
||||
func createFullStudio(id int, parentID int) models.Studio {
|
||||
return models.Studio{
|
||||
ID: id,
|
||||
Name: models.NullString(studioName),
|
||||
URL: models.NullString(url),
|
||||
ParentID: models.NullInt64(int64(parentID)),
|
||||
ret := models.Studio{
|
||||
ID: id,
|
||||
Name: models.NullString(studioName),
|
||||
URL: models.NullString(url),
|
||||
Details: models.NullString(details),
|
||||
CreatedAt: models.SQLiteTimestamp{
|
||||
Timestamp: createTime,
|
||||
},
|
||||
@@ -53,6 +56,12 @@ func createFullStudio(id int, parentID int) models.Studio {
|
||||
Timestamp: updateTime,
|
||||
},
|
||||
}
|
||||
|
||||
if parentID != 0 {
|
||||
ret.ParentID = models.NullInt64(int64(parentID))
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func createEmptyStudio(id int) models.Studio {
|
||||
@@ -69,8 +78,9 @@ func createEmptyStudio(id int) models.Studio {
|
||||
|
||||
func createFullJSONStudio(parentStudio, image string) *jsonschema.Studio {
|
||||
return &jsonschema.Studio{
|
||||
Name: studioName,
|
||||
URL: url,
|
||||
Name: studioName,
|
||||
URL: url,
|
||||
Details: details,
|
||||
CreatedAt: models.JSONTime{
|
||||
Time: createTime,
|
||||
},
|
||||
|
||||
@@ -28,6 +28,7 @@ func (i *Importer) PreImport() error {
|
||||
Checksum: checksum,
|
||||
Name: sql.NullString{String: i.Input.Name, Valid: true},
|
||||
URL: sql.NullString{String: i.Input.URL, Valid: true},
|
||||
Details: sql.NullString{String: i.Input.Details, Valid: true},
|
||||
CreatedAt: models.SQLiteTimestamp{Timestamp: i.Input.CreatedAt.GetTime()},
|
||||
UpdatedAt: models.SQLiteTimestamp{Timestamp: i.Input.UpdatedAt.GetTime()},
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/stashapp/stash/pkg/manager/jsonschema"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"github.com/stashapp/stash/pkg/models/mocks"
|
||||
"github.com/stashapp/stash/pkg/utils"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/mock"
|
||||
)
|
||||
@@ -51,6 +52,17 @@ func TestImporterPreImport(t *testing.T) {
|
||||
err = i.PreImport()
|
||||
|
||||
assert.Nil(t, err)
|
||||
|
||||
i.Input = *createFullJSONStudio(studioName, image)
|
||||
i.Input.ParentStudio = ""
|
||||
|
||||
err = i.PreImport()
|
||||
|
||||
assert.Nil(t, err)
|
||||
expectedStudio := createFullStudio(0, 0)
|
||||
expectedStudio.ParentID.Valid = false
|
||||
expectedStudio.Checksum = utils.MD5FromString(studioName)
|
||||
assert.Equal(t, expectedStudio, i.studio)
|
||||
}
|
||||
|
||||
func TestImporterPreImportWithParent(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user