From 0cdea209bb94a75370546fa525e64bdd55fb3b23 Mon Sep 17 00:00:00 2001 From: DingDongSoLong4 <99329275+DingDongSoLong4@users.noreply.github.com> Date: Fri, 22 Dec 2023 12:40:05 +0200 Subject: [PATCH] Fix stats page SUM error (#4390) --- pkg/sqlite/image.go | 2 +- pkg/sqlite/scene.go | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/sqlite/image.go b/pkg/sqlite/image.go index c9bb521d3..bfc9e6dc6 100644 --- a/pkg/sqlite/image.go +++ b/pkg/sqlite/image.go @@ -622,7 +622,7 @@ func (qb *ImageStore) Size(ctx context.Context) (float64, error) { table := qb.table() fileTable := fileTableMgr.table q := dialect.Select( - goqu.SUM(fileTableMgr.table.Col("size")), + goqu.COALESCE(goqu.SUM(fileTableMgr.table.Col("size")), 0), ).From(table).InnerJoin( imagesFilesJoinTable, goqu.On(table.Col(idColumn).Eq(imagesFilesJoinTable.Col(imageIDColumn))), diff --git a/pkg/sqlite/scene.go b/pkg/sqlite/scene.go index b576b54eb..c32e76fdf 100644 --- a/pkg/sqlite/scene.go +++ b/pkg/sqlite/scene.go @@ -779,7 +779,7 @@ func (qb *SceneStore) Size(ctx context.Context) (float64, error) { table := qb.table() fileTable := fileTableMgr.table q := dialect.Select( - goqu.SUM(fileTableMgr.table.Col("size")), + goqu.COALESCE(goqu.SUM(fileTableMgr.table.Col("size")), 0), ).From(table).InnerJoin( scenesFilesJoinTable, goqu.On(table.Col(idColumn).Eq(scenesFilesJoinTable.Col(sceneIDColumn))), @@ -800,7 +800,8 @@ func (qb *SceneStore) Duration(ctx context.Context) (float64, error) { videoFileTable := videoFileTableMgr.table q := dialect.Select( - goqu.SUM(videoFileTable.Col("duration"))).From(table).InnerJoin( + goqu.COALESCE(goqu.SUM(videoFileTable.Col("duration")), 0), + ).From(table).InnerJoin( scenesFilesJoinTable, goqu.On(scenesFilesJoinTable.Col("scene_id").Eq(table.Col(idColumn))), ).InnerJoin(