From 87167736f692b11da08cc029050041abab3ae520 Mon Sep 17 00:00:00 2001 From: WithoutPants <53250216+WithoutPants@users.noreply.github.com> Date: Mon, 8 Aug 2022 14:55:39 +1000 Subject: [PATCH] [Files Refactor] bug fixes (#2811) * Fix scan options not saving * Fix duration stat calculation --- internal/manager/manager_tasks.go | 2 +- pkg/sqlite/scene.go | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/internal/manager/manager_tasks.go b/internal/manager/manager_tasks.go index 1453ad74f..3572bf6f0 100644 --- a/internal/manager/manager_tasks.go +++ b/internal/manager/manager_tasks.go @@ -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"` diff --git a/pkg/sqlite/scene.go b/pkg/sqlite/scene.go index e11eb0f0e..5e5d8dca1 100644 --- a/pkg/sqlite/scene.go +++ b/pkg/sqlite/scene.go @@ -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