mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
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:
@@ -3,6 +3,7 @@ package performer
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"github.com/stashapp/stash/pkg/models/json"
|
||||
@@ -24,7 +25,6 @@ func ToJSON(ctx context.Context, reader ImageStashIDGetter, performer *models.Pe
|
||||
Ethnicity: performer.Ethnicity,
|
||||
Country: performer.Country,
|
||||
EyeColor: performer.EyeColor,
|
||||
Height: performer.Height,
|
||||
Measurements: performer.Measurements,
|
||||
FakeTits: performer.FakeTits,
|
||||
CareerLength: performer.CareerLength,
|
||||
@@ -50,6 +50,11 @@ func ToJSON(ctx context.Context, reader ImageStashIDGetter, performer *models.Pe
|
||||
if performer.DeathDate != nil {
|
||||
newPerformerJSON.DeathDate = performer.DeathDate.String()
|
||||
}
|
||||
|
||||
if performer.Height != nil {
|
||||
newPerformerJSON.Height = strconv.Itoa(*performer.Height)
|
||||
}
|
||||
|
||||
if performer.Weight != nil {
|
||||
newPerformerJSON.Weight = *performer.Weight
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package performer
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strconv"
|
||||
|
||||
"github.com/stashapp/stash/pkg/hash/md5"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
@@ -30,7 +31,6 @@ const (
|
||||
eyeColor = "eyeColor"
|
||||
fakeTits = "fakeTits"
|
||||
gender = "gender"
|
||||
height = "height"
|
||||
instagram = "instagram"
|
||||
measurements = "measurements"
|
||||
piercings = "piercings"
|
||||
@@ -44,6 +44,7 @@ const (
|
||||
|
||||
var (
|
||||
rating = 5
|
||||
height = 123
|
||||
weight = 60
|
||||
)
|
||||
|
||||
@@ -82,7 +83,7 @@ func createFullPerformer(id int, name string) *models.Performer {
|
||||
FakeTits: fakeTits,
|
||||
Favorite: true,
|
||||
Gender: gender,
|
||||
Height: height,
|
||||
Height: &height,
|
||||
Instagram: instagram,
|
||||
Measurements: measurements,
|
||||
Piercings: piercings,
|
||||
@@ -120,7 +121,7 @@ func createFullJSONPerformer(name string, image string) *jsonschema.Performer {
|
||||
FakeTits: fakeTits,
|
||||
Favorite: true,
|
||||
Gender: gender,
|
||||
Height: height,
|
||||
Height: strconv.Itoa(height),
|
||||
Instagram: instagram,
|
||||
Measurements: measurements,
|
||||
Piercings: piercings,
|
||||
|
||||
@@ -3,9 +3,11 @@ package performer
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/stashapp/stash/pkg/hash/md5"
|
||||
"github.com/stashapp/stash/pkg/logger"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"github.com/stashapp/stash/pkg/models/jsonschema"
|
||||
"github.com/stashapp/stash/pkg/sliceutil/stringslice"
|
||||
@@ -194,7 +196,6 @@ func performerJSONToPerformer(performerJSON jsonschema.Performer) models.Perform
|
||||
Ethnicity: performerJSON.Ethnicity,
|
||||
Country: performerJSON.Country,
|
||||
EyeColor: performerJSON.EyeColor,
|
||||
Height: performerJSON.Height,
|
||||
Measurements: performerJSON.Measurements,
|
||||
FakeTits: performerJSON.FakeTits,
|
||||
CareerLength: performerJSON.CareerLength,
|
||||
@@ -235,5 +236,14 @@ func performerJSONToPerformer(performerJSON jsonschema.Performer) models.Perform
|
||||
newPerformer.Weight = &performerJSON.Weight
|
||||
}
|
||||
|
||||
if performerJSON.Height != "" {
|
||||
h, err := strconv.Atoi(performerJSON.Height)
|
||||
if err == nil {
|
||||
newPerformer.Height = &h
|
||||
} else {
|
||||
logger.Warnf("error parsing height %q: %v", performerJSON.Height, err)
|
||||
}
|
||||
}
|
||||
|
||||
return newPerformer
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user