Change performer height to be numeric (#3060)

* Make height an int. Add height_cm field
* Change UI to use height_cm
* Use number fields for height/weight
* Add migration note
This commit is contained in:
WithoutPants
2022-11-08 14:09:03 +11:00
committed by GitHub
parent b9e07ade92
commit d2743cf5fb
35 changed files with 432 additions and 99 deletions

View File

@@ -84,7 +84,16 @@ func scrapedToPerformerInput(performer *models.ScrapedPerformer) models.Performe
ret.HairColor = *performer.HairColor
}
if performer.Height != nil {
ret.Height = *performer.Height
h, err := strconv.Atoi(*performer.Height) // height is stored as an int
if err == nil {
ret.Height = &h
}
}
if performer.Weight != nil {
h, err := strconv.Atoi(*performer.Weight)
if err == nil {
ret.Weight = &h
}
}
if performer.Measurements != nil {
ret.Measurements = *performer.Measurements

View File

@@ -10,6 +10,7 @@ import (
"github.com/stashapp/stash/pkg/models"
"github.com/stashapp/stash/pkg/models/mocks"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)
@@ -233,7 +234,7 @@ func Test_scrapedToPerformerInput(t *testing.T) {
md5 := "b068931cc450442b63f5b3d276ea4297"
var stringValues []string
for i := 0; i < 16; i++ {
for i := 0; i < 17; i++ {
stringValues = append(stringValues, strconv.Itoa(i))
}
@@ -244,6 +245,12 @@ func Test_scrapedToPerformerInput(t *testing.T) {
return &ret
}
nextIntVal := func() *int {
ret := upTo
upTo = (upTo + 1) % len(stringValues)
return &ret
}
dateToDatePtr := func(d models.Date) *models.Date {
return &d
}
@@ -265,6 +272,7 @@ func Test_scrapedToPerformerInput(t *testing.T) {
EyeColor: nextVal(),
HairColor: nextVal(),
Height: nextVal(),
Weight: nextVal(),
Measurements: nextVal(),
FakeTits: nextVal(),
CareerLength: nextVal(),
@@ -284,7 +292,8 @@ func Test_scrapedToPerformerInput(t *testing.T) {
Country: *nextVal(),
EyeColor: *nextVal(),
HairColor: *nextVal(),
Height: *nextVal(),
Height: nextIntVal(),
Weight: nextIntVal(),
Measurements: *nextVal(),
FakeTits: *nextVal(),
CareerLength: *nextVal(),
@@ -314,9 +323,7 @@ func Test_scrapedToPerformerInput(t *testing.T) {
got.CreatedAt = time.Time{}
got.UpdatedAt = got.CreatedAt
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("scrapedToPerformerInput() = %v, want %v", got, tt.want)
}
assert.Equal(t, tt.want, got)
})
}
}