From 835ee4b823b57c479a5e0cd64b08d581dba9dcba Mon Sep 17 00:00:00 2001 From: Lekuru Date: Tue, 27 Feb 2024 18:52:53 +0100 Subject: [PATCH] Add beatmapset count queries --- database/repositories/beatmapsets.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/database/repositories/beatmapsets.py b/database/repositories/beatmapsets.py index 628ec02..26a9148 100644 --- a/database/repositories/beatmapsets.py +++ b/database/repositories/beatmapsets.py @@ -258,6 +258,25 @@ def search_extended( .limit(limit) \ .all() +@session_wrapper +def fetch_count( + user_id: int, + session: Session | None = None +) -> int: + return session.query(DBBeatmapset) \ + .filter(DBBeatmapset.creator_id == user_id) \ + .count() + +@session_wrapper +def fetch_ranked_count( + user_id: int, + session: Session | None = None +) -> int: + return session.query(DBBeatmapset) \ + .filter(DBBeatmapset.creator_id == user_id) \ + .filter(DBBeatmapset.status > 0) \ + .count() + @session_wrapper def update( beatmapset_id: int,