1
0
mirror of https://github.com/immich-app/immich.git synced 2024-11-24 08:52:28 +02:00

fix(server): server stats showing wrong quota usage (#10036)

* Add filter to exclude external libraries from the user quota usage

* Add filter to exclude external libraries from the user quota usage

* fix sql syntax
This commit is contained in:
Alejandro Armas 2024-06-08 06:56:11 -03:00 committed by GitHub
parent 62f8bd80f4
commit 3c5ba77e86
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View File

@ -130,7 +130,13 @@ SELECT
"assets"."type" = 'VIDEO'
AND "assets"."isVisible"
) AS "videos",
COALESCE(SUM("exif"."fileSizeInByte"), 0) AS "usage"
COALESCE(
SUM("exif"."fileSizeInByte") FILTER (
WHERE
"assets"."libraryId" IS NULL
),
0
) AS "usage"
FROM
"users" "users"
LEFT JOIN "assets" "assets" ON "assets"."ownerId" = "users"."id"

View File

@ -108,7 +108,7 @@ export class UserRepository implements IUserRepository {
.addSelect('users.name', 'userName')
.addSelect(`COUNT(assets.id) FILTER (WHERE assets.type = 'IMAGE' AND assets.isVisible)`, 'photos')
.addSelect(`COUNT(assets.id) FILTER (WHERE assets.type = 'VIDEO' AND assets.isVisible)`, 'videos')
.addSelect('COALESCE(SUM(exif.fileSizeInByte), 0)', 'usage')
.addSelect('COALESCE(SUM(exif.fileSizeInByte) FILTER (WHERE assets.libraryId IS NULL), 0)', 'usage')
.addSelect('users.quotaSizeInBytes', 'quotaSizeInBytes')
.leftJoin('users.assets', 'assets')
.leftJoin('assets.exifInfo', 'exif')