fix sql, counter show 0
All checks were successful
/ release (push) Successful in 46s

This commit is contained in:
Samuel Lorch 2025-03-19 23:13:08 +01:00
parent a5fc856764
commit 15a960da19
2 changed files with 5 additions and 1 deletions

View file

@ -91,6 +91,10 @@ func handleIndex(w http.ResponseWriter, r *http.Request) {
}
func splitInt(n int) []int {
if n == 0 {
return []int{0}
}
slc := []int{}
for n > 0 {
slc = append(slc, n%10)

View file

@ -341,7 +341,7 @@ func handleStats(w http.ResponseWriter, r *http.Request) {
var saved int
err = db.QueryRow(r.Context(),
`SELECT (SUM(old_size) - COALESCE(SUM(size), 0)) AS saved
FROM files WHERE ($1 = -1 OR files.library_id = $1) AND status = $2 AND old_size NOT NULL`, id, constants.FILE_STATUS_EXISTS).Scan(&saved)
FROM files WHERE ($1 = -1 OR files.library_id = $1) AND status = $2 AND old_size IS NOT NULL`, id, constants.FILE_STATUS_EXISTS).Scan(&saved)
if err != nil {
saved = 0
}