Skip to content

Commit 98c78e4

Browse files
authored
🐛 Fixed items count when retrieving data for all items by user (#695)
1 parent 5373286 commit 98c78e4

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

backend/app/api/routes/items.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,18 @@ def read_items(
1717
Retrieve items.
1818
"""
1919

20-
statment = select(func.count()).select_from(Item)
21-
count = session.exec(statment).one()
22-
2320
if current_user.is_superuser:
21+
statment = select(func.count()).select_from(Item)
22+
count = session.exec(statment).one()
2423
statement = select(Item).offset(skip).limit(limit)
2524
items = session.exec(statement).all()
2625
else:
26+
statment = (
27+
select(func.count())
28+
.select_from(Item)
29+
.where(Item.owner_id == current_user.id)
30+
)
31+
count = session.exec(statment).one()
2732
statement = (
2833
select(Item)
2934
.where(Item.owner_id == current_user.id)

0 commit comments

Comments
 (0)