[Files Refactor] bug fixes (#2811)

* Fix scan options not saving
* Fix duration stat calculation
This commit is contained in:
WithoutPants 2022-08-08 14:55:39 +10:00
parent 569c3a872a
commit 87167736f6
2 changed files with 13 additions and 2 deletions

View File

@ -63,7 +63,7 @@ func (s *Manager) ScanSubscribe(ctx context.Context) <-chan bool {
type ScanMetadataInput struct {
Paths []string `json:"paths"`
config.ScanMetadataOptions
config.ScanMetadataOptions `mapstructure:",squash"`
// Filter options for the scan
Filter *ScanMetaDataFilterInput `json:"filter"`

View File

@ -642,7 +642,18 @@ func (qb *SceneStore) Size(ctx context.Context) (float64, error) {
}
func (qb *SceneStore) Duration(ctx context.Context) (float64, error) {
q := dialect.Select(goqu.SUM(qb.queryTable().Col("duration"))).From(qb.queryTable())
table := qb.table()
videoFileTable := videoFileTableMgr.table
q := dialect.Select(
goqu.SUM(videoFileTable.Col("duration"))).From(table).InnerJoin(
scenesFilesJoinTable,
goqu.On(scenesFilesJoinTable.Col("scene_id").Eq(table.Col(idColumn))),
).InnerJoin(
videoFileTable,
goqu.On(videoFileTable.Col("file_id").Eq(scenesFilesJoinTable.Col("file_id"))),
)
var ret float64
if err := querySimple(ctx, q, &ret); err != nil {
return 0, err