99
1010
1111class PlayerCheckpoints (BaseModel ):
12+ """Body for adding or updating **Checkpoint** time"""
13+
1214 steamid : str
1315 mapname : str
1416 cp : int
@@ -48,18 +50,18 @@ async def insertOrUpdateCheckpoints(
4850 )
4951 xquery = insertQuery (sql )
5052 content_data = {"inserted" : xquery , "xtime" : time .perf_counter () - tic }
51-
53+
5254 if xquery < 1 :
5355 # response.body = json.dumps(content_data).encode('utf-8')
54- response .headers [' content-type' ] = ' application/json'
56+ response .headers [" content-type" ] = " application/json"
5557 response .status_code = status .HTTP_304_NOT_MODIFIED
5658 return response
5759
5860 # Prepare the response
5961 toc = time .perf_counter ()
6062 print (f"Execution time { toc - tic :0.4f} " )
61-
62- response .body = json .dumps (content_data ).encode (' utf-8' )
63+
64+ response .body = json .dumps (content_data ).encode (" utf-8" )
6365 response .status_code = status .HTTP_201_CREATED
6466 return response
6567
@@ -81,7 +83,8 @@ async def selectCheckpoints(
8183 if cached_data is not None :
8284 print (f"[Redis] Loaded '{ cache_key } ' ({ time .perf_counter () - tic :0.4f} s)" )
8385 return JSONResponse (
84- status_code = status .HTTP_200_OK , content = json .loads (cached_data , use_decimal = True , parse_nan = True )
86+ status_code = status .HTTP_200_OK ,
87+ content = json .loads (cached_data , use_decimal = True , parse_nan = True ),
8588 )
8689
8790 xquery = selectQuery (
@@ -126,7 +129,8 @@ async def selectCheckpointsinZoneGroup(
126129 if cached_data is not None :
127130 print (f"[Redis] Loaded '{ cache_key } ' ({ time .perf_counter () - tic :0.4f} s)" )
128131 return JSONResponse (
129- status_code = status .HTTP_200_OK , content = json .loads (cached_data , use_decimal = True , parse_nan = True )
132+ status_code = status .HTTP_200_OK ,
133+ content = json .loads (cached_data , use_decimal = True , parse_nan = True ),
130134 )
131135
132136 xquery = selectQuery (
@@ -168,7 +172,8 @@ async def selectRecordCheckpoints(
168172 if cached_data is not None :
169173 print (f"[Redis] Loaded '{ cache_key } ' ({ time .perf_counter () - tic :0.4f} s)" )
170174 return JSONResponse (
171- status_code = status .HTTP_200_OK , content = json .loads (cached_data , use_decimal = True , parse_nan = True )
175+ status_code = status .HTTP_200_OK ,
176+ content = json .loads (cached_data , use_decimal = True , parse_nan = True ),
172177 )
173178
174179 xquery = selectQuery (
@@ -211,18 +216,19 @@ async def deleteCheckpoints(
211216 content_data = {"deleted" : xquery , "xtime" : time .perf_counter () - tic }
212217 if xquery < 1 :
213218 # response.body = json.dumps(content_data).encode('utf-8')
214- response .headers [' content-type' ] = ' application/json'
219+ response .headers [" content-type" ] = " application/json"
215220 response .status_code = status .HTTP_304_NOT_MODIFIED
216221 return response
217222
218223 toc = time .perf_counter ()
219224 print (f"Execution time { toc - tic :0.4f} " )
220225
221- response .body = json .dumps (content_data ).encode (' utf-8' )
222- response .headers [' content-type' ] = ' application/json'
226+ response .body = json .dumps (content_data ).encode (" utf-8" )
227+ response .headers [" content-type" ] = " application/json"
223228 response .status_code = status .HTTP_200_OK
224229 return response
225230
231+
226232@router .get (
227233 "/surftimer/selectStageTimes" ,
228234 name = "Get Stage Times" ,
@@ -240,7 +246,8 @@ async def selectStageTimes(
240246 if cached_data is not None :
241247 print (f"[Redis] Loaded '{ cache_key } ' ({ time .perf_counter () - tic :0.4f} s)" )
242248 return JSONResponse (
243- status_code = status .HTTP_200_OK , content = json .loads (cached_data , use_decimal = True , parse_nan = True )
249+ status_code = status .HTTP_200_OK ,
250+ content = json .loads (cached_data , use_decimal = True , parse_nan = True ),
244251 )
245252
246253 xquery = selectQuery (
@@ -280,7 +287,8 @@ async def selectStageAttempts(
280287 if cached_data is not None :
281288 print (f"[Redis] Loaded '{ cache_key } ' ({ time .perf_counter () - tic :0.4f} s)" )
282289 return JSONResponse (
283- status_code = status .HTTP_200_OK , content = json .loads (cached_data , use_decimal = True , parse_nan = True )
290+ status_code = status .HTTP_200_OK ,
291+ content = json .loads (cached_data , use_decimal = True , parse_nan = True ),
284292 )
285293
286294 xquery = selectQuery (
0 commit comments