Browse Source
🐛 Fixed items count when retrieving data for all items by user (#695)
pull/13907/head
Esteban Maya
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
8 additions and
3 deletions
-
backend/app/api/routes/items.py
|
|
@ -17,13 +17,18 @@ def read_items( |
|
|
|
Retrieve items. |
|
|
|
""" |
|
|
|
|
|
|
|
statment = select(func.count()).select_from(Item) |
|
|
|
count = session.exec(statment).one() |
|
|
|
|
|
|
|
if current_user.is_superuser: |
|
|
|
statment = select(func.count()).select_from(Item) |
|
|
|
count = session.exec(statment).one() |
|
|
|
statement = select(Item).offset(skip).limit(limit) |
|
|
|
items = session.exec(statement).all() |
|
|
|
else: |
|
|
|
statment = ( |
|
|
|
select(func.count()) |
|
|
|
.select_from(Item) |
|
|
|
.where(Item.owner_id == current_user.id) |
|
|
|
) |
|
|
|
count = session.exec(statment).one() |
|
|
|
statement = ( |
|
|
|
select(Item) |
|
|
|
.where(Item.owner_id == current_user.id) |
|
|
|