Files
silo-server/internal/models/library_collection.go
T
Silo Server Migration dce8978cdf Track template poster origin in collection sync
- add poster_from_template to collection records and update flows
- preserve template-applied posters while keeping admin uploads sticky
- improve template bundle sync/status reporting and MDBList limit handling
2026-05-23 14:19:04 -04:00

106 lines
2.9 KiB
Go

package models
import (
"encoding/json"
"time"
)
// LibraryCollection is an admin-managed collection scoped to one or more libraries.
type LibraryCollection struct {
ID string
LibraryID int
LibraryIDs []int
Slug string
Title string
Description string
CollectionType string
Visibility string
SortOrder int
GroupID *string
Featured bool
PosterURL string
BackdropURL string
PosterThumbhash string
BackdropThumbhash string
PosterAutoGenerated bool
// PosterFromTemplate flags posters set by a template bundle apply.
// ensureTemplatePoster sets this true; the guard treats template-origin
// posters as refreshable so template poster updates propagate, while
// admin-uploaded posters (PosterAutoGenerated=false AND PosterFromTemplate=false)
// remain sticky.
PosterFromTemplate bool
SourceURL string
QueryDefinition json.RawMessage
SortConfig json.RawMessage
SourceConfig json.RawMessage
ManagementMode string
ManagementSource string
ManagementKey string
LastSyncStatus string
LastSyncMessage string
LastSyncAt *time.Time
SyncSchedule *string
NextSyncAt *time.Time
ItemCount int
CreatedAt time.Time
UpdatedAt time.Time
}
type LibraryCollectionGroupKind string
const (
GroupKindRegular LibraryCollectionGroupKind = "regular"
GroupKindUserCollections LibraryCollectionGroupKind = "user_collections"
)
type GroupSortMode string
const (
GroupSortManual GroupSortMode = "manual"
GroupSortNameAsc GroupSortMode = "name_asc"
GroupSortNameDesc GroupSortMode = "name_desc"
GroupSortRecent GroupSortMode = "recent"
GroupSortMostItems GroupSortMode = "most_items"
)
// LibraryCollectionGroup is a per-library bucket that groups collections in the
// gallery view. Collections without a group_id fall into the implicit
// "Ungrouped" section that lives outside this table.
type LibraryCollectionGroup struct {
ID string
LibraryID int
Name string
Slug string
Kind LibraryCollectionGroupKind
DefaultSortMode GroupSortMode
SortOrder int
CreatedAt time.Time
UpdatedAt time.Time
}
// LibraryCollectionItem is a resolved membership entry for a library collection.
type LibraryCollectionItem struct {
CollectionID string
MediaItemID string
Position int
SourceRank int
CreatedAt time.Time
UpdatedAt time.Time
}
// LibraryCollectionSyncRun captures the outcome of a collection sync/import run.
type LibraryCollectionSyncRun struct {
ID string
CollectionID string
Status string
Message string
ItemsAdded int
ItemsRemoved int
ItemsMatched int
ItemsUnmatched int
Warnings json.RawMessage
StartedAt *time.Time
CompletedAt *time.Time
CreatedAt time.Time
}