Files
stash/pkg/models/gallery.go
WithoutPants 5495d72849 File storage rewrite (#2676)
* Restructure data layer part 2 (#2599)
* Refactor and separate image model
* Refactor image query builder
* Handle relationships in image query builder
* Remove relationship management methods
* Refactor gallery model/query builder
* Add scenes to gallery model
* Convert scene model
* Refactor scene models
* Remove unused methods
* Add unit tests for gallery
* Add image tests
* Add scene tests
* Convert unnecessary scene value pointers to values
* Convert unnecessary pointer values to values
* Refactor scene partial
* Add scene partial tests
* Refactor ImagePartial
* Add image partial tests
* Refactor gallery partial update
* Add partial gallery update tests
* Use zero/null package for null values
* Add files and scan system
* Add sqlite implementation for files/folders
* Add unit tests for files/folders
* Image refactors
* Update image data layer
* Refactor gallery model and creation
* Refactor scene model
* Refactor scenes
* Don't set title from filename
* Allow galleries to freely add/remove images
* Add multiple scene file support to graphql and UI
* Add multiple file support for images in graphql/UI
* Add multiple file for galleries in graphql/UI
* Remove use of some deprecated fields
* Remove scene path usage
* Remove gallery path usage
* Remove path from image
* Move funscript to video file
* Refactor caption detection
* Migrate existing data
* Add post commit/rollback hook system
* Lint. Comment out import/export tests
* Add WithDatabase read only wrapper
* Prepend tasks to list
* Add 32 pre-migration
* Add warnings in release and migration notes
2022-09-06 07:03:42 +00:00

102 lines
4.1 KiB
Go

package models
import (
"context"
"github.com/stashapp/stash/pkg/file"
)
type GalleryFilterType struct {
And *GalleryFilterType `json:"AND"`
Or *GalleryFilterType `json:"OR"`
Not *GalleryFilterType `json:"NOT"`
Title *StringCriterionInput `json:"title"`
Details *StringCriterionInput `json:"details"`
// Filter by file checksum
Checksum *StringCriterionInput `json:"checksum"`
// Filter by path
Path *StringCriterionInput `json:"path"`
// Filter to only include galleries missing this property
IsMissing *string `json:"is_missing"`
// Filter to include/exclude galleries that were created from zip
IsZip *bool `json:"is_zip"`
// Filter by rating
Rating *IntCriterionInput `json:"rating"`
// Filter by organized
Organized *bool `json:"organized"`
// Filter by average image resolution
AverageResolution *ResolutionCriterionInput `json:"average_resolution"`
// Filter to only include galleries with this studio
Studios *HierarchicalMultiCriterionInput `json:"studios"`
// Filter to only include galleries with these tags
Tags *HierarchicalMultiCriterionInput `json:"tags"`
// Filter by tag count
TagCount *IntCriterionInput `json:"tag_count"`
// Filter to only include galleries with performers with these tags
PerformerTags *HierarchicalMultiCriterionInput `json:"performer_tags"`
// Filter to only include galleries with these performers
Performers *MultiCriterionInput `json:"performers"`
// Filter by performer count
PerformerCount *IntCriterionInput `json:"performer_count"`
// Filter galleries that have performers that have been favorited
PerformerFavorite *bool `json:"performer_favorite"`
// Filter galleries by performer age at time of gallery
PerformerAge *IntCriterionInput `json:"performer_age"`
// Filter by number of images in this gallery
ImageCount *IntCriterionInput `json:"image_count"`
// Filter by url
URL *StringCriterionInput `json:"url"`
}
type GalleryUpdateInput struct {
ClientMutationID *string `json:"clientMutationId"`
ID string `json:"id"`
Title *string `json:"title"`
URL *string `json:"url"`
Date *string `json:"date"`
Details *string `json:"details"`
Rating *int `json:"rating"`
Organized *bool `json:"organized"`
SceneIds []string `json:"scene_ids"`
StudioID *string `json:"studio_id"`
TagIds []string `json:"tag_ids"`
PerformerIds []string `json:"performer_ids"`
}
type GalleryDestroyInput struct {
Ids []string `json:"ids"`
// If true, then the zip file will be deleted if the gallery is zip-file-based.
// If gallery is folder-based, then any files not associated with other
// galleries will be deleted, along with the folder, if it is not empty.
DeleteFile *bool `json:"delete_file"`
DeleteGenerated *bool `json:"delete_generated"`
}
type GalleryReader interface {
Find(ctx context.Context, id int) (*Gallery, error)
FindMany(ctx context.Context, ids []int) ([]*Gallery, error)
FindByChecksum(ctx context.Context, checksum string) ([]*Gallery, error)
FindByChecksums(ctx context.Context, checksums []string) ([]*Gallery, error)
FindByPath(ctx context.Context, path string) ([]*Gallery, error)
FindBySceneID(ctx context.Context, sceneID int) ([]*Gallery, error)
FindByImageID(ctx context.Context, imageID int) ([]*Gallery, error)
Count(ctx context.Context) (int, error)
All(ctx context.Context) ([]*Gallery, error)
Query(ctx context.Context, galleryFilter *GalleryFilterType, findFilter *FindFilterType) ([]*Gallery, int, error)
QueryCount(ctx context.Context, galleryFilter *GalleryFilterType, findFilter *FindFilterType) (int, error)
GetImageIDs(ctx context.Context, galleryID int) ([]int, error)
}
type GalleryWriter interface {
Create(ctx context.Context, newGallery *Gallery, fileIDs []file.ID) error
Update(ctx context.Context, updatedGallery *Gallery) error
UpdatePartial(ctx context.Context, id int, updatedGallery GalleryPartial) (*Gallery, error)
Destroy(ctx context.Context, id int) error
UpdateImages(ctx context.Context, galleryID int, imageIDs []int) error
}
type GalleryReaderWriter interface {
GalleryReader
GalleryWriter
}