Skip to content

Commit

Permalink
cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
extreme4all authored Feb 1, 2024
1 parent 8a6dcdc commit 1f6e948
Showing 1 changed file with 0 additions and 15 deletions.
15 changes: 0 additions & 15 deletions src/api/v1/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,19 +342,6 @@ async def insert_report(
@router.get("/report/count", tags=["Report"])
async def get_report_count_v1(name: str):
"""
objective is to make this query
SELECT COUNT(*) AS `count_1`,
`subject` . `confirmed_ban`,
`subject` . `possible_ban`,
`subject` . `confirmed_player`
FROM (
SELECT DISTINCT `Reports` . `reportedID`
FROM `Reports`
INNER JOIN `Players` AS `voter` ON `Reports` . `reportingID` = `voter` . `id`
WHERE `voter` . `name` = ? AND `Reports` . `manual_detect` = ?
) AS DistinctReports
INNER JOIN `Players` AS `subject` ON DistinctReports.`reportedID` = `subject` . `id`
GROUP BY `subject` . `confirmed_ban`, `subject` . `possible_ban`, `subject` . `confirmed_player`;
"""
name = await functions.to_jagex_name(name)

Expand Down Expand Up @@ -384,14 +371,12 @@ async def get_report_count_v1(name: str):
)

keys = ["count", "confirmed_ban", "possible_ban", "confirmed_player"]
PLAYERDATA_ENGINE.engine.echo = True
# execute query
async with PLAYERDATA_ENGINE.get_session() as session:
session: AsyncSession = session
async with session.begin():
data = await session.execute(sql)
data = [{k: v for k, v in zip(keys, d)} for d in data]
PLAYERDATA_ENGINE.engine.echo = False
return data


Expand Down

0 comments on commit 1f6e948

Please sign in to comment.