mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Model refactor (#3915)
* Add mockery config file * Move basic file/folder structs to models * Fix hack due to import loop * Move file interfaces to models * Move folder interfaces to models * Move scene interfaces to models * Move scene marker interfaces to models * Move image interfaces to models * Move gallery interfaces to models * Move gallery chapter interfaces to models * Move studio interfaces to models * Move movie interfaces to models * Move performer interfaces to models * Move tag interfaces to models * Move autotag interfaces to models * Regenerate mocks
This commit is contained in:
@@ -1,10 +1,6 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/stashapp/stash/pkg/file"
|
||||
)
|
||||
import "context"
|
||||
|
||||
type PHashDuplicationCriterionInput struct {
|
||||
Duplicated *bool `json:"duplicated"`
|
||||
@@ -112,7 +108,7 @@ type SceneQueryResult struct {
|
||||
TotalDuration float64
|
||||
TotalSize float64
|
||||
|
||||
finder SceneFinder
|
||||
getter SceneGetter
|
||||
scenes []*Scene
|
||||
resolveErr error
|
||||
}
|
||||
@@ -129,83 +125,16 @@ type ScenesDestroyInput struct {
|
||||
DeleteGenerated *bool `json:"delete_generated"`
|
||||
}
|
||||
|
||||
func NewSceneQueryResult(finder SceneFinder) *SceneQueryResult {
|
||||
func NewSceneQueryResult(getter SceneGetter) *SceneQueryResult {
|
||||
return &SceneQueryResult{
|
||||
finder: finder,
|
||||
getter: getter,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *SceneQueryResult) Resolve(ctx context.Context) ([]*Scene, error) {
|
||||
// cache results
|
||||
if r.scenes == nil && r.resolveErr == nil {
|
||||
r.scenes, r.resolveErr = r.finder.FindMany(ctx, r.IDs)
|
||||
r.scenes, r.resolveErr = r.getter.FindMany(ctx, r.IDs)
|
||||
}
|
||||
return r.scenes, r.resolveErr
|
||||
}
|
||||
|
||||
type SceneFinder interface {
|
||||
// TODO - rename this to Find and remove existing method
|
||||
FindMany(ctx context.Context, ids []int) ([]*Scene, error)
|
||||
}
|
||||
|
||||
type SceneReader interface {
|
||||
SceneFinder
|
||||
// TODO - remove this in another PR
|
||||
Find(ctx context.Context, id int) (*Scene, error)
|
||||
FindByChecksum(ctx context.Context, checksum string) ([]*Scene, error)
|
||||
FindByOSHash(ctx context.Context, oshash string) ([]*Scene, error)
|
||||
FindByPath(ctx context.Context, path string) ([]*Scene, error)
|
||||
FindByPerformerID(ctx context.Context, performerID int) ([]*Scene, error)
|
||||
FindByGalleryID(ctx context.Context, performerID int) ([]*Scene, error)
|
||||
FindDuplicates(ctx context.Context, distance int, durationDiff float64) ([][]*Scene, error)
|
||||
|
||||
URLLoader
|
||||
GalleryIDLoader
|
||||
PerformerIDLoader
|
||||
TagIDLoader
|
||||
SceneMovieLoader
|
||||
StashIDLoader
|
||||
VideoFileLoader
|
||||
|
||||
CountByPerformerID(ctx context.Context, performerID int) (int, error)
|
||||
OCountByPerformerID(ctx context.Context, performerID int) (int, error)
|
||||
OCount(ctx context.Context) (int, error)
|
||||
// FindByStudioID(studioID int) ([]*Scene, error)
|
||||
FindByMovieID(ctx context.Context, movieID int) ([]*Scene, error)
|
||||
CountByMovieID(ctx context.Context, movieID int) (int, error)
|
||||
Count(ctx context.Context) (int, error)
|
||||
PlayCount(ctx context.Context) (int, error)
|
||||
UniqueScenePlayCount(ctx context.Context) (int, error)
|
||||
Size(ctx context.Context) (float64, error)
|
||||
Duration(ctx context.Context) (float64, error)
|
||||
PlayDuration(ctx context.Context) (float64, error)
|
||||
// SizeCount() (string, error)
|
||||
CountByStudioID(ctx context.Context, studioID int) (int, error)
|
||||
CountByTagID(ctx context.Context, tagID int) (int, error)
|
||||
CountMissingChecksum(ctx context.Context) (int, error)
|
||||
CountMissingOSHash(ctx context.Context) (int, error)
|
||||
Wall(ctx context.Context, q *string) ([]*Scene, error)
|
||||
All(ctx context.Context) ([]*Scene, error)
|
||||
Query(ctx context.Context, options SceneQueryOptions) (*SceneQueryResult, error)
|
||||
QueryCount(ctx context.Context, sceneFilter *SceneFilterType, findFilter *FindFilterType) (int, error)
|
||||
GetCover(ctx context.Context, sceneID int) ([]byte, error)
|
||||
HasCover(ctx context.Context, sceneID int) (bool, error)
|
||||
}
|
||||
|
||||
type SceneWriter interface {
|
||||
Create(ctx context.Context, newScene *Scene, fileIDs []file.ID) error
|
||||
Update(ctx context.Context, updatedScene *Scene) error
|
||||
UpdatePartial(ctx context.Context, id int, updatedScene ScenePartial) (*Scene, error)
|
||||
IncrementOCounter(ctx context.Context, id int) (int, error)
|
||||
DecrementOCounter(ctx context.Context, id int) (int, error)
|
||||
ResetOCounter(ctx context.Context, id int) (int, error)
|
||||
SaveActivity(ctx context.Context, id int, resumeTime *float64, playDuration *float64) (bool, error)
|
||||
IncrementWatchCount(ctx context.Context, id int) (int, error)
|
||||
Destroy(ctx context.Context, id int) error
|
||||
UpdateCover(ctx context.Context, sceneID int, cover []byte) error
|
||||
}
|
||||
|
||||
type SceneReaderWriter interface {
|
||||
SceneReader
|
||||
SceneWriter
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user