2020-09-15 07:28:53 +00:00
|
|
|
package models
|
|
|
|
|
2021-10-25 00:40:13 +00:00
|
|
|
type SceneQueryOptions struct {
|
|
|
|
QueryOptions
|
|
|
|
SceneFilter *SceneFilterType
|
|
|
|
|
|
|
|
TotalDuration bool
|
|
|
|
TotalSize bool
|
|
|
|
}
|
|
|
|
|
|
|
|
type SceneQueryResult struct {
|
|
|
|
QueryResult
|
|
|
|
TotalDuration float64
|
2021-10-27 00:55:11 +00:00
|
|
|
TotalSize float64
|
2021-10-25 00:40:13 +00:00
|
|
|
|
|
|
|
finder SceneFinder
|
|
|
|
scenes []*Scene
|
|
|
|
resolveErr error
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewSceneQueryResult(finder SceneFinder) *SceneQueryResult {
|
|
|
|
return &SceneQueryResult{
|
|
|
|
finder: finder,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *SceneQueryResult) Resolve() ([]*Scene, error) {
|
|
|
|
// cache results
|
|
|
|
if r.scenes == nil && r.resolveErr == nil {
|
|
|
|
r.scenes, r.resolveErr = r.finder.FindMany(r.IDs)
|
|
|
|
}
|
|
|
|
return r.scenes, r.resolveErr
|
|
|
|
}
|
|
|
|
|
|
|
|
type SceneFinder interface {
|
|
|
|
// TODO - rename this to Find and remove existing method
|
|
|
|
FindMany(ids []int) ([]*Scene, error)
|
|
|
|
}
|
|
|
|
|
2020-09-15 07:28:53 +00:00
|
|
|
type SceneReader interface {
|
2021-10-25 00:40:13 +00:00
|
|
|
SceneFinder
|
|
|
|
// TODO - remove this in another PR
|
2021-01-18 01:23:20 +00:00
|
|
|
Find(id int) (*Scene, error)
|
2020-09-20 08:36:02 +00:00
|
|
|
FindByChecksum(checksum string) (*Scene, error)
|
|
|
|
FindByOSHash(oshash string) (*Scene, error)
|
2021-01-18 01:23:20 +00:00
|
|
|
FindByPath(path string) (*Scene, error)
|
|
|
|
FindByPerformerID(performerID int) ([]*Scene, error)
|
2021-02-01 20:56:54 +00:00
|
|
|
FindByGalleryID(performerID int) ([]*Scene, error)
|
2021-04-11 23:04:40 +00:00
|
|
|
FindDuplicates(distance int) ([][]*Scene, error)
|
2021-01-18 01:23:20 +00:00
|
|
|
CountByPerformerID(performerID int) (int, error)
|
2020-09-15 07:28:53 +00:00
|
|
|
// FindByStudioID(studioID int) ([]*Scene, error)
|
2020-10-30 22:41:12 +00:00
|
|
|
FindByMovieID(movieID int) ([]*Scene, error)
|
2021-01-18 01:23:20 +00:00
|
|
|
CountByMovieID(movieID int) (int, error)
|
|
|
|
Count() (int, error)
|
|
|
|
Size() (float64, error)
|
2021-08-26 03:37:08 +00:00
|
|
|
Duration() (float64, error)
|
2020-09-15 07:28:53 +00:00
|
|
|
// SizeCount() (string, error)
|
2021-01-18 01:23:20 +00:00
|
|
|
CountByStudioID(studioID int) (int, error)
|
|
|
|
CountByTagID(tagID int) (int, error)
|
|
|
|
CountMissingChecksum() (int, error)
|
|
|
|
CountMissingOSHash() (int, error)
|
|
|
|
Wall(q *string) ([]*Scene, error)
|
2020-09-15 07:28:53 +00:00
|
|
|
All() ([]*Scene, error)
|
2021-10-25 00:40:13 +00:00
|
|
|
Query(options SceneQueryOptions) (*SceneQueryResult, error)
|
2022-05-06 01:59:28 +00:00
|
|
|
GetCaptions(sceneID int) ([]*SceneCaption, error)
|
2021-01-18 01:23:20 +00:00
|
|
|
GetCover(sceneID int) ([]byte, error)
|
|
|
|
GetMovies(sceneID int) ([]MoviesScenes, error)
|
2021-02-01 20:56:54 +00:00
|
|
|
GetTagIDs(sceneID int) ([]int, error)
|
|
|
|
GetGalleryIDs(sceneID int) ([]int, error)
|
|
|
|
GetPerformerIDs(sceneID int) ([]int, error)
|
|
|
|
GetStashIDs(sceneID int) ([]*StashID, error)
|
2020-09-15 07:28:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type SceneWriter interface {
|
2020-09-20 08:36:02 +00:00
|
|
|
Create(newScene Scene) (*Scene, error)
|
|
|
|
Update(updatedScene ScenePartial) (*Scene, error)
|
|
|
|
UpdateFull(updatedScene Scene) (*Scene, error)
|
2021-01-18 01:23:20 +00:00
|
|
|
IncrementOCounter(id int) (int, error)
|
|
|
|
DecrementOCounter(id int) (int, error)
|
|
|
|
ResetOCounter(id int) (int, error)
|
|
|
|
UpdateFileModTime(id int, modTime NullSQLiteTimestamp) error
|
|
|
|
Destroy(id int) error
|
2022-05-06 01:59:28 +00:00
|
|
|
UpdateCaptions(id int, captions []*SceneCaption) error
|
2021-01-18 01:23:20 +00:00
|
|
|
UpdateCover(sceneID int, cover []byte) error
|
|
|
|
DestroyCover(sceneID int) error
|
|
|
|
UpdatePerformers(sceneID int, performerIDs []int) error
|
|
|
|
UpdateTags(sceneID int, tagIDs []int) error
|
2021-02-01 20:56:54 +00:00
|
|
|
UpdateGalleries(sceneID int, galleryIDs []int) error
|
2021-01-18 01:23:20 +00:00
|
|
|
UpdateMovies(sceneID int, movies []MoviesScenes) error
|
|
|
|
UpdateStashIDs(sceneID int, stashIDs []StashID) error
|
2020-09-15 07:28:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type SceneReaderWriter interface {
|
|
|
|
SceneReader
|
|
|
|
SceneWriter
|
|
|
|
}
|