Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added details, deathdate, hair color, weight to performers and added details to studios #1274

Merged
merged 13 commits into from Apr 16, 2021
Merged
4 changes: 4 additions & 0 deletions graphql/documents/data/performer.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ fragment PerformerData on Performer {
stash_id
endpoint
}
details
deathdate
This conversation was marked as resolved.
Show resolved Hide resolved
hair_color
weight
}
8 changes: 8 additions & 0 deletions graphql/documents/data/scrapers.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ fragment ScrapedPerformerData on ScrapedPerformer {
...ScrapedSceneTagData
}
image
details
deathdate
hair_color
weight
}

fragment ScrapedScenePerformerData on ScrapedScenePerformer {
Expand All @@ -44,6 +48,10 @@ fragment ScrapedScenePerformerData on ScrapedScenePerformer {
}
remote_site_id
images
details
deathdate
hair_color
weight
}

fragment ScrapedMovieStudioData on ScrapedMovieStudio {
Expand Down
1 change: 1 addition & 0 deletions graphql/documents/data/studio-slim.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ fragment SlimStudioData on Studio {
parent_studio {
id
}
details
}
1 change: 1 addition & 0 deletions graphql/documents/data/studio.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ fragment StudioData on Studio {
stash_id
endpoint
}
details
}
10 changes: 9 additions & 1 deletion graphql/documents/mutations/performer.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ mutation PerformerCreate(
$favorite: Boolean,
$tag_ids: [ID!],
$stash_ids: [StashIDInput!],
$image: String) {
$image: String
$details: String,
$deathdate: String,
$hair_color: String,
$weight: String) {

performerCreate(input: {
name: $name,
Expand All @@ -41,6 +45,10 @@ mutation PerformerCreate(
tag_ids: $tag_ids,
stash_ids: $stash_ids,
image: $image
details: $details,
deathdate: $deathdate,
hair_color: $hair_color,
weight: $weight
}) {
...PerformerData
}
Expand Down
5 changes: 3 additions & 2 deletions graphql/documents/mutations/studio.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ mutation StudioCreate(
$url: String,
$image: String,
$stash_ids: [StashIDInput!],
$parent_id: ID) {
$parent_id: ID
$details: String) {

studioCreate(input: { name: $name, url: $url, image: $image, stash_ids: $stash_ids, parent_id: $parent_id }) {
studioCreate(input: { name: $name, url: $url, image: $image, stash_ids: $stash_ids, parent_id: $parent_id, details: $details }) {
...StudioData
}
}
Expand Down
4 changes: 4 additions & 0 deletions graphql/documents/queries/scrapers/freeones.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ query ScrapeFreeones($performer_name: String!) {
tattoos
piercings
aliases
details
deathdate
hair_color
weight
}
}

Expand Down
6 changes: 6 additions & 0 deletions graphql/schema/types/filters.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ input PerformerFilterType {
stash_id: String
"""Filter by url"""
url: StringCriterionInput
"""Filter by hair color"""
hair_color: StringCriterionInput
"""Filter by weight"""
weight: StringCriterionInput
"""Filter by death year"""
death_year: IntCriterionInput
}

input SceneMarkerFilterType {
Expand Down
16 changes: 16 additions & 0 deletions graphql/schema/types/performer.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ type Performer {
scene_count: Int # Resolver
scenes: [Scene!]!
stash_ids: [StashID!]!
details: String
deathdate: String
hair_color: String
weight: String
This conversation was marked as resolved.
Show resolved Hide resolved
}

input PerformerCreateInput {
Expand All @@ -57,6 +61,10 @@ input PerformerCreateInput {
"""This should be a URL or a base64 encoded data URL"""
image: String
stash_ids: [StashIDInput!]
details: String
deathdate: String
hair_color: String
weight: String
}

input PerformerUpdateInput {
Expand All @@ -82,6 +90,10 @@ input PerformerUpdateInput {
"""This should be a URL or a base64 encoded data URL"""
image: String
stash_ids: [StashIDInput!]
details: String
deathdate: String
hair_color: String
weight: String
}

input BulkPerformerUpdateInput {
Expand All @@ -104,6 +116,10 @@ input BulkPerformerUpdateInput {
instagram: String
favorite: Boolean
tag_ids: BulkUpdateIds
details: String
deathdate: String
hair_color: String
weight: String
}

input PerformerDestroyInput {
Expand Down
8 changes: 8 additions & 0 deletions graphql/schema/types/scraped-performer.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ type ScrapedPerformer {

"""This should be a base64 encoded data URL"""
image: String
details: String
deathdate: String
hair_color: String
weight: String
}

input ScrapedPerformerInput {
Expand All @@ -43,4 +47,8 @@ input ScrapedPerformerInput {

# not including tags for the input
# not including image for the input
details: String
deathdate: String
hair_color: String
weight: String
}
4 changes: 4 additions & 0 deletions graphql/schema/types/scraper.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ type ScrapedScenePerformer {

remote_site_id: String
images: [String!]
details: String
deathdate: String
hair_color: String
weight: String
}

type ScrapedSceneMovie {
Expand Down
3 changes: 3 additions & 0 deletions graphql/schema/types/studio.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type Studio {
image_path: String # Resolver
scene_count: Int # Resolver
stash_ids: [StashID!]!
details: String
}

input StudioCreateInput {
Expand All @@ -18,6 +19,7 @@ input StudioCreateInput {
"""This should be a URL or a base64 encoded data URL"""
image: String
stash_ids: [StashIDInput!]
details: String
}

input StudioUpdateInput {
Expand All @@ -28,6 +30,7 @@ input StudioUpdateInput {
"""This should be a URL or a base64 encoded data URL"""
image: String
stash_ids: [StashIDInput!]
details: String
}

input StudioDestroyInput {
Expand Down
5 changes: 5 additions & 0 deletions graphql/stash-box/query.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ fragment PerformerFragment on Performer {
piercings {
...BodyModificationFragment
}
details
deathdate {
...FuzzyDateFragment
}
weight
}

fragment PerformerAppearanceFragment on PerformerAppearance {
Expand Down
28 changes: 28 additions & 0 deletions pkg/api/resolver_model_performer.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,31 @@ func (r *performerResolver) StashIds(ctx context.Context, obj *models.Performer)

return ret, nil
}

func (r *performerResolver) Details(ctx context.Context, obj *models.Performer) (*string, error) {
if obj.Details.Valid {
return &obj.Details.String, nil
}
return nil, nil
}

func (r *performerResolver) Deathdate(ctx context.Context, obj *models.Performer) (*string, error) {
if obj.Deathdate.Valid {
return &obj.Deathdate.String, nil
}
return nil, nil
}

func (r *performerResolver) HairColor(ctx context.Context, obj *models.Performer) (*string, error) {
if obj.HairColor.Valid {
return &obj.HairColor.String, nil
}
return nil, nil
}

func (r *performerResolver) Weight(ctx context.Context, obj *models.Performer) (*string, error) {
if obj.Weight.Valid {
return &obj.Weight.String, nil
}
return nil, nil
}
7 changes: 7 additions & 0 deletions pkg/api/resolver_model_studio.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,10 @@ func (r *studioResolver) StashIds(ctx context.Context, obj *models.Studio) (ret

return ret, nil
}

func (r *studioResolver) Details(ctx context.Context, obj *models.Studio) (*string, error) {
if obj.Details.Valid {
return &obj.Details.String, nil
}
return nil, nil
}
39 changes: 39 additions & 0 deletions pkg/api/resolver_mutation_performer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package api
import (
"context"
"database/sql"
"errors"
"strconv"
"time"

Expand Down Expand Up @@ -83,6 +84,24 @@ func (r *mutationResolver) PerformerCreate(ctx context.Context, input models.Per
} else {
newPerformer.Favorite = sql.NullBool{Bool: false, Valid: true}
}
if input.Details != nil {
newPerformer.Details = sql.NullString{String: *input.Details, Valid: true}
}
if input.Deathdate != nil {
newPerformer.Deathdate = models.SQLiteDate{String: *input.Deathdate, Valid: true}

if *input.Deathdate != "" {
if utils.IfDateHigherThanAnotherDate(*input.Birthdate, *input.Deathdate) {
return nil, errors.New("The date of Death should be higher than the date of Birth")
This conversation was marked as resolved.
Show resolved Hide resolved
}
}
}
if input.HairColor != nil {
newPerformer.HairColor = sql.NullString{String: *input.HairColor, Valid: true}
}
if input.Weight != nil {
newPerformer.Weight = sql.NullString{String: *input.Weight, Valid: true}
}

// Start the transaction and save the performer
var performer *models.Performer
Expand Down Expand Up @@ -153,6 +172,12 @@ func (r *mutationResolver) PerformerUpdate(ctx context.Context, input models.Per
updatedPerformer.Checksum = &checksum
}

if *input.Deathdate != "" {
This conversation was marked as resolved.
Show resolved Hide resolved
if utils.IfDateHigherThanAnotherDate(*input.Birthdate, *input.Deathdate) {
This conversation was marked as resolved.
Show resolved Hide resolved
return nil, errors.New("The date of Death should be higher than the date of Birth")
}
}

updatedPerformer.URL = translator.nullString(input.URL, "url")

if translator.hasField("gender") {
Expand All @@ -177,6 +202,10 @@ func (r *mutationResolver) PerformerUpdate(ctx context.Context, input models.Per
updatedPerformer.Twitter = translator.nullString(input.Twitter, "twitter")
updatedPerformer.Instagram = translator.nullString(input.Instagram, "instagram")
updatedPerformer.Favorite = translator.nullBool(input.Favorite, "favorite")
updatedPerformer.Details = translator.nullString(input.Details, "details")
updatedPerformer.Deathdate = translator.sqliteDate(input.Deathdate, "deathdate")
updatedPerformer.HairColor = translator.nullString(input.HairColor, "hair_color")
updatedPerformer.Weight = translator.nullString(input.Weight, "weight")

// Start the transaction and save the performer
var performer *models.Performer
Expand Down Expand Up @@ -264,6 +293,10 @@ func (r *mutationResolver) BulkPerformerUpdate(ctx context.Context, input models
updatedPerformer.Twitter = translator.nullString(input.Twitter, "twitter")
updatedPerformer.Instagram = translator.nullString(input.Instagram, "instagram")
updatedPerformer.Favorite = translator.nullBool(input.Favorite, "favorite")
updatedPerformer.Details = translator.nullString(input.Details, "details")
updatedPerformer.Deathdate = translator.sqliteDate(input.Deathdate, "deathdate")
updatedPerformer.HairColor = translator.nullString(input.HairColor, "hair_color")
updatedPerformer.Weight = translator.nullString(input.Weight, "weight")

if translator.hasField("gender") {
if input.Gender != nil {
Expand All @@ -273,6 +306,12 @@ func (r *mutationResolver) BulkPerformerUpdate(ctx context.Context, input models
}
}

if *input.Deathdate != "" {
if utils.IfDateHigherThanAnotherDate(*input.Birthdate, *input.Deathdate) {
return nil, errors.New("The date of Death should be higher than the date of Birth")
}
}

ret := []*models.Performer{}

// Start the transaction and save the scene marker
Expand Down
5 changes: 5 additions & 0 deletions pkg/api/resolver_mutation_studio.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ func (r *mutationResolver) StudioCreate(ctx context.Context, input models.Studio
newStudio.ParentID = sql.NullInt64{Int64: parentID, Valid: true}
}

if input.Details != nil {
newStudio.Details = sql.NullString{String: *input.Details, Valid: true}
}

// Start the transaction and save the studio
var studio *models.Studio
if err := r.withTxn(ctx, func(repo models.Repository) error {
Expand Down Expand Up @@ -109,6 +113,7 @@ func (r *mutationResolver) StudioUpdate(ctx context.Context, input models.Studio
}

updatedStudio.URL = translator.nullString(input.URL, "url")
updatedStudio.Details = translator.nullString(input.Details, "details")
updatedStudio.ParentID = translator.nullInt64FromString(input.ParentID, "parent_id")

// Start the transaction and save the studio
Expand Down
2 changes: 1 addition & 1 deletion pkg/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
var DB *sqlx.DB
var WriteMu *sync.Mutex
var dbPath string
var appSchemaVersion uint = 20
var appSchemaVersion uint = 21
var databaseSchemaVersion uint

var (
Expand Down
5 changes: 5 additions & 0 deletions pkg/database/migrations/21_performers_studios_details.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ALTER TABLE `performers` ADD COLUMN `details` text;
ALTER TABLE `performers` ADD COLUMN `deathdate` date;
ALTER TABLE `performers` ADD COLUMN `hair_color` varchar(255);
ALTER TABLE `performers` ADD COLUMN `weight` varchar(255);
ALTER TABLE `studios` ADD COLUMN `details` text;
4 changes: 4 additions & 0 deletions pkg/manager/jsonschema/performer.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ type Performer struct {
Image string `json:"image,omitempty"`
CreatedAt models.JSONTime `json:"created_at,omitempty"`
UpdatedAt models.JSONTime `json:"updated_at,omitempty"`
Details string `json:"details,omitempty"`
Deathdate string `json:"deathdate,omitempty"`
HairColor string `json:"hair_color,omitempty"`
Weight string `json:"weight,omitempty"`
}

func LoadPerformerFile(filePath string) (*Performer, error) {
Expand Down
1 change: 1 addition & 0 deletions pkg/manager/jsonschema/studio.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type Studio struct {
Image string `json:"image,omitempty"`
CreatedAt models.JSONTime `json:"created_at,omitempty"`
UpdatedAt models.JSONTime `json:"updated_at,omitempty"`
Details string `json:"details,omitempty"`
}

func LoadStudioFile(filePath string) (*Studio, error) {
Expand Down
Loading