mirror of
https://github.com/hay-kot/homebox.git
synced 2024-12-18 13:06:32 +00:00
fix: use item quantity as count mechanism (#304)
This commit is contained in:
parent
859d3b9ffe
commit
3ac6c7c858
1 changed files with 8 additions and 2 deletions
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue