Feature: Support Multiple URLs in Studios (#6223)

* Backend support for studio URLs
* FrontEnd addition
* Support URLs in BulkStudioUpdate
* Update tagger modal for URLs
---------
Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
Gykes
2025-11-09 19:34:21 -08:00
committed by GitHub
parent 12a9a0b5f6
commit f434c1f529
33 changed files with 451 additions and 69 deletions

View File

@@ -18,8 +18,12 @@ import (
)
const (
studioTable = "studios"
studioIDColumn = "studio_id"
studioTable = "studios"
studioIDColumn = "studio_id"
studioURLsTable = "studio_urls"
studioURLColumn = "url"
studioAliasesTable = "studio_aliases"
studioAliasColumn = "alias"
studioParentIDColumn = "parent_id"
@@ -31,7 +35,6 @@ const (
type studioRow struct {
ID int `db:"id" goqu:"skipinsert"`
Name zero.String `db:"name"`
URL zero.String `db:"url"`
ParentID null.Int `db:"parent_id,omitempty"`
CreatedAt Timestamp `db:"created_at"`
UpdatedAt Timestamp `db:"updated_at"`
@@ -48,7 +51,6 @@ type studioRow struct {
func (r *studioRow) fromStudio(o models.Studio) {
r.ID = o.ID
r.Name = zero.StringFrom(o.Name)
r.URL = zero.StringFrom(o.URL)
r.ParentID = intFromPtr(o.ParentID)
r.CreatedAt = Timestamp{Timestamp: o.CreatedAt}
r.UpdatedAt = Timestamp{Timestamp: o.UpdatedAt}
@@ -62,7 +64,6 @@ func (r *studioRow) resolve() *models.Studio {
ret := &models.Studio{
ID: r.ID,
Name: r.Name.String,
URL: r.URL.String,
ParentID: nullIntPtr(r.ParentID),
CreatedAt: r.CreatedAt.Timestamp,
UpdatedAt: r.UpdatedAt.Timestamp,
@@ -81,7 +82,6 @@ type studioRowRecord struct {
func (r *studioRowRecord) fromPartial(o models.StudioPartial) {
r.setNullString("name", o.Name)
r.setNullString("url", o.URL)
r.setNullInt("parent_id", o.ParentID)
r.setTimestamp("created_at", o.CreatedAt)
r.setTimestamp("updated_at", o.UpdatedAt)
@@ -190,6 +190,13 @@ func (qb *StudioStore) Create(ctx context.Context, newObject *models.Studio) err
}
}
if newObject.URLs.Loaded() {
const startPos = 0
if err := studiosURLsTableMgr.insertJoins(ctx, id, startPos, newObject.URLs.List()); err != nil {
return err
}
}
if err := qb.tagRelationshipStore.createRelationships(ctx, id, newObject.TagIDs); err != nil {
return err
}
@@ -234,6 +241,12 @@ func (qb *StudioStore) UpdatePartial(ctx context.Context, input models.StudioPar
}
}
if input.URLs != nil {
if err := studiosURLsTableMgr.modifyJoins(ctx, input.ID, input.URLs.Values, input.URLs.Mode); err != nil {
return nil, err
}
}
if err := qb.tagRelationshipStore.modifyRelationships(ctx, input.ID, input.TagIDs); err != nil {
return nil, err
}
@@ -262,6 +275,12 @@ func (qb *StudioStore) Update(ctx context.Context, updatedObject *models.Studio)
}
}
if updatedObject.URLs.Loaded() {
if err := studiosURLsTableMgr.replaceJoins(ctx, updatedObject.ID, updatedObject.URLs.List()); err != nil {
return err
}
}
if err := qb.tagRelationshipStore.replaceRelationships(ctx, updatedObject.ID, updatedObject.TagIDs); err != nil {
return err
}
@@ -507,7 +526,7 @@ func (qb *StudioStore) QueryForAutoTag(ctx context.Context, words []string) ([]*
ret, err := qb.findBySubquery(ctx, sq)
if err != nil {
return nil, fmt.Errorf("getting performers for autotag: %w", err)
return nil, fmt.Errorf("getting studios for autotag: %w", err)
}
return ret, nil
@@ -663,3 +682,7 @@ func (qb *StudioStore) GetStashIDs(ctx context.Context, studioID int) ([]models.
func (qb *StudioStore) GetAliases(ctx context.Context, studioID int) ([]string, error) {
return studiosAliasesTableMgr.get(ctx, studioID)
}
func (qb *StudioStore) GetURLs(ctx context.Context, studioID int) ([]string, error) {
return studiosURLsTableMgr.get(ctx, studioID)
}