diff --git a/backend/internal/data/repo/repo_locations.go b/backend/internal/data/repo/repo_locations.go index 2d3ea56..25a17f0 100644 --- a/backend/internal/data/repo/repo_locations.go +++ b/backend/internal/data/repo/repo_locations.go @@ -105,7 +105,7 @@ func (r *LocationRepository) GetAll(ctx context.Context, GID uuid.UUID, filter L updated_at, ( SELECT - COUNT(*) + SUM(items.quantity) FROM items WHERE @@ -135,11 +135,17 @@ func (r *LocationRepository) GetAll(ctx context.Context, GID uuid.UUID, filter L for rows.Next() { var ct LocationOutCount - err := rows.Scan(&ct.ID, &ct.Name, &ct.Description, &ct.CreatedAt, &ct.UpdatedAt, &ct.ItemCount) + var maybeCount *int + + err := rows.Scan(&ct.ID, &ct.Name, &ct.Description, &ct.CreatedAt, &ct.UpdatedAt, &maybeCount) if err != nil { return nil, err } + if maybeCount != nil { + ct.ItemCount = *maybeCount + } + list = append(list, ct) }