Skip to content

Commit

Permalink
chore:update endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jingooo5 committed Nov 2, 2024
1 parent 1fb5d0b commit 1eb2c98
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Service/useritem_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@ def get_all_userItem(user_id: str):
with get_db() as db:
return db.query(UserItem).filter(UserItem.user_id == user_id, UserItem.count > 0).all()

def get_all_userItem_filtered_by_category(user_id: str, category: str):
with get_db() as db:
return db.query(UserItem).filter(UserItem.user_id == user_id, UserItem.count > 0).join(Item).filter(Item.item_category == category).all()

def get_all_userItem_filtered_by_date(user_id, year: int, month: int):
with get_db() as db:
return db.query(UserItem).filter(UserItem.user_id == user_id, extract("year", UserItem.consume_date) == year,
extract("month", UserItem.consume_date) == month).all()


def to_userItem_dict(userItemList: List[UserItem]):
def to_userItem_dict(userItemList: List[UserItem], category: str):
itemlist = []

for userItem in userItemList:
Expand Down

0 comments on commit 1eb2c98

Please sign in to comment.