@@ -291,8 +291,12 @@ async def product_stats(response: Response,
291
291
# )
292
292
# out2 = await cur.fetchone()
293
293
# import pdb;pdb.set_trace()
294
- return JSONResponse (status_code = 200 , content = out [0 ], headers = {"x-pg-timing" :timing })
295
294
295
+ return JSONResponse (
296
+ status_code = 200 ,
297
+ content = out [0 ] if out and out [0 ] is not None else [],
298
+ headers = {"x-pg-timing" : timing }
299
+ )
296
300
297
301
@app .get ("/products" , response_model = List [ProductList ])
298
302
async def product_list (response : Response ,
@@ -320,8 +324,12 @@ async def product_list(response: Response,
320
324
params
321
325
)
322
326
out = await cur .fetchone ()
323
- return JSONResponse (status_code = 200 , content = out [0 ], headers = {"x-pg-timing" :timing })
324
327
328
+ return JSONResponse (
329
+ status_code = 200 ,
330
+ content = out [0 ] if out and out [0 ] is not None else [],
331
+ headers = {"x-pg-timing" : timing }
332
+ )
325
333
326
334
@app .get ("/product/{product}" , response_model = List [ProductTag ])
327
335
async def product_tags_list (response : Response ,
@@ -340,9 +348,13 @@ async def product_tags_list(response: Response,
340
348
(product , owner ),
341
349
)
342
350
out = await cur .fetchone ()
343
- return JSONResponse (status_code = 200 , content = out [0 ], headers = {"x-pg-timing" : timing })
344
-
345
351
352
+ return JSONResponse (
353
+ status_code = 200 ,
354
+ content = out [0 ] if out and out [0 ] is not None else [],
355
+ headers = {"x-pg-timing" : timing }
356
+ )
357
+
346
358
@app .get ("/product/{product}/{k}" , response_model = ProductTag )
347
359
async def product_tag (response : Response ,
348
360
product : str , k : str , owner = '' ,
@@ -379,10 +391,12 @@ async def product_tag(response: Response,
379
391
(product , owner , key ),
380
392
)
381
393
out = await cur .fetchone ()
382
- if out :
383
- return JSONResponse (status_code = 200 , content = out [0 ], headers = {"x-pg-timing" : timing })
384
- else :
385
- return JSONResponse (status_code = 404 , content = None )
394
+
395
+ return JSONResponse (
396
+ status_code = 200 ,
397
+ content = out [0 ] if out and out [0 ] is not None else [],
398
+ headers = {"x-pg-timing" : timing }
399
+ )
386
400
387
401
388
402
@app .get ("/product/{product}/{k}/versions" , response_model = List [ProductTag ])
@@ -407,7 +421,13 @@ async def product_tag_list_versions(response: Response,
407
421
(product , owner , k ),
408
422
)
409
423
out = await cur .fetchone ()
410
- return JSONResponse (status_code = 200 , content = out [0 ], headers = {"x-pg-timing" : timing })
424
+
425
+ return JSONResponse (
426
+ status_code = 200 ,
427
+ content = out [0 ] if out and out [0 ] is not None else [],
428
+ headers = {"x-pg-timing" : timing }
429
+ )
430
+
411
431
412
432
413
433
@app .post ("/product" )
@@ -569,8 +589,12 @@ async def keys_list(response: Response,
569
589
(owner ,)
570
590
)
571
591
out = await cur .fetchone ()
572
- return JSONResponse (status_code = 200 , content = out [0 ], headers = {"x-pg-timing" : timing })
573
592
593
+ return JSONResponse (
594
+ status_code = 200 ,
595
+ content = out [0 ] if out and out [0 ] is not None else [],
596
+ headers = {"x-pg-timing" : timing }
597
+ )
574
598
575
599
@app .get ("/values/{k}" , response_model = List [ValueCount ])
576
600
async def get_unique_values (response : Response ,
0 commit comments