Skip to content

Commit 2e17afd

Browse files
committed
all ck_latestrecords stray queries
1 parent 36fa99f commit 2e17afd

3 files changed

Lines changed: 39 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ SurfTimer FastAPI
1111
- [ ] ck_announcements
1212
- [x] ck_bonus
1313
- [x] ck_checkpoints
14-
- [x] ck_latestrecords - Partially
14+
- [x] ck_latestrecords
1515
- [x] ck_maptier - Partially
1616
- [x] ck_playeroptions2 - Partially
1717
- [x] ck_playerrank - Partially

surftimer/ck_latestrecords.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,36 @@ async def insertLatestRecord(request: Request, response: Response, data: LatestR
9090
response.body = json.dumps(content_data).encode("utf-8")
9191
response.status_code = status.HTTP_201_CREATED
9292
return response
93+
94+
95+
@router.delete(
96+
"/surftimer/deleteWipePlayerLatestRecords",
97+
name="Wipe Player Latest Records",
98+
tags=["ck_latestrecords", "strays"],
99+
)
100+
async def deleteWipePlayerLatestRecords(
101+
request: Request,
102+
response: Response,
103+
steamid32: str,
104+
):
105+
"""```char sql_stray_deleteWipePlayerLatestRecords[] = ....```"""
106+
tic = time.perf_counter()
107+
108+
xquery = insertQuery(
109+
surftimer.queries.sql_stray_deleteWipePlayerLatestRecords.format(steamid32)
110+
)
111+
112+
content_data = {"deleted": xquery, "xtime": time.perf_counter() - tic}
113+
if xquery < 1:
114+
# response.body = json.dumps(content_data).encode('utf-8')
115+
response.headers["content-type"] = "application/json"
116+
response.status_code = status.HTTP_304_NOT_MODIFIED
117+
return response
118+
119+
toc = time.perf_counter()
120+
print(f"Execution time {toc - tic:0.4f}")
121+
122+
response.body = json.dumps(content_data).encode("utf-8")
123+
response.headers["content-type"] = "application/json"
124+
response.status_code = status.HTTP_200_OK
125+
return response

surftimer/queries.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,3 +206,8 @@
206206
)
207207
sql_stray_selectCPR = "SELECT cp, time FROM ck_checkpoints WHERE steamid = '%s' AND mapname = '%s' AND zonegroup = 0;"
208208
sql_stray_ccp_getPlayerPR = "SELECT db1.steamid, db1.mapname, db1.cp, db1.stage_time, db1.stage_attempts, (SELECT count(name)+1 FROM ck_wrcps WHERE style = 0 AND mapname = db1.mapname AND stage = db1.cp AND stage_time > -1.0 AND runtimepro <= db1.stage_time) AS `rank`, (SELECT count(name) FROM ck_wrcps WHERE style = 0 AND mapname = db1.mapname AND stage = db1.cp AND runtimepro > -1.0) AS total FROM ck_checkpoints db1 WHERE db1.mapname = '%s' AND db1.steamid = '%s' AND db1.stage_time > -1.0 ORDER BY cp ASC;"
209+
210+
# latestrecords
211+
sql_stray_deleteWipePlayerLatestRecords = (
212+
"DELETE FROM ck_latestrecords WHERE steamid = '%s';"
213+
)

0 commit comments

Comments
 (0)