[Files Refactor] Performance tuning (#2819)

* Load scene relationships on demand
* Load image relationships on demand
* Load gallery relationships on demand
* Add dataloaden
* Use dataloaders
* Use where in for other find many functions
This commit is contained in:
WithoutPants
2022-08-12 12:21:46 +10:00
parent 9b31b20fed
commit 00608c167a
317 changed files with 28002 additions and 14875 deletions

View File

@@ -30,9 +30,13 @@ type StudioFilterType struct {
IgnoreAutoTag *bool `json:"ignore_auto_tag"`
}
type StudioFinder interface {
FindMany(ctx context.Context, ids []int) ([]*Studio, error)
}
type StudioReader interface {
Find(ctx context.Context, id int) (*Studio, error)
FindMany(ctx context.Context, ids []int) ([]*Studio, error)
StudioFinder
FindChildren(ctx context.Context, id int) ([]*Studio, error)
FindByName(ctx context.Context, name string, nocase bool) (*Studio, error)
FindByStashID(ctx context.Context, stashID StashID) ([]*Studio, error)
@@ -44,7 +48,7 @@ type StudioReader interface {
Query(ctx context.Context, studioFilter *StudioFilterType, findFilter *FindFilterType) ([]*Studio, int, error)
GetImage(ctx context.Context, studioID int) ([]byte, error)
HasImage(ctx context.Context, studioID int) (bool, error)
GetStashIDs(ctx context.Context, studioID int) ([]*StashID, error)
StashIDLoader
GetAliases(ctx context.Context, studioID int) ([]string, error)
}
@@ -55,7 +59,7 @@ type StudioWriter interface {
Destroy(ctx context.Context, id int) error
UpdateImage(ctx context.Context, studioID int, image []byte) error
DestroyImage(ctx context.Context, studioID int) error
UpdateStashIDs(ctx context.Context, studioID int, stashIDs []*StashID) error
UpdateStashIDs(ctx context.Context, studioID int, stashIDs []StashID) error
UpdateAliases(ctx context.Context, studioID int, aliases []string) error
}