Show duration and filesize in results (#1776)

* Add new query interface
* Refactor query builder
* Change Query interface
* Return duration and filesize in scene query
* Adjust UI for scene metadata
* Introduce new image query interface
* Change image Query interface
* Add megapixels and size to image query
* Update image UI

Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
kermieisinthehouse
2021-10-24 17:40:13 -07:00
committed by GitHub
parent 1b411e3f43
commit 4dd56c3d82
49 changed files with 788 additions and 229 deletions

View File

@@ -1,8 +1,46 @@
package models
type SceneReader interface {
Find(id int) (*Scene, error)
type SceneQueryOptions struct {
QueryOptions
SceneFilter *SceneFilterType
TotalDuration bool
TotalSize bool
}
type SceneQueryResult struct {
QueryResult
TotalDuration float64
TotalSize int
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)
}
type SceneReader interface {
SceneFinder
// TODO - remove this in another PR
Find(id int) (*Scene, error)
FindByChecksum(checksum string) (*Scene, error)
FindByOSHash(oshash string) (*Scene, error)
FindByPath(path string) (*Scene, error)
@@ -23,7 +61,7 @@ type SceneReader interface {
CountMissingOSHash() (int, error)
Wall(q *string) ([]*Scene, error)
All() ([]*Scene, error)
Query(sceneFilter *SceneFilterType, findFilter *FindFilterType) ([]*Scene, int, error)
Query(options SceneQueryOptions) (*SceneQueryResult, error)
GetCover(sceneID int) ([]byte, error)
GetMovies(sceneID int) ([]MoviesScenes, error)
GetTagIDs(sceneID int) ([]int, error)