Fix partial fetching
All checks were successful
Build and Publish college-bot-v2 / build_and_publish (push) Successful in 14s
All checks were successful
Build and Publish college-bot-v2 / build_and_publish (push) Successful in 14s
This commit is contained in:
parent
a9126fd123
commit
6f98c86ea7
1 changed files with 7 additions and 7 deletions
|
@ -11,6 +11,8 @@ from fastapi.responses import JSONResponse, Response
|
|||
from fastapi.security import HTTPBasic, HTTPBasicCredentials
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from symbol import return_stmt
|
||||
|
||||
JSON: typing.Union[
|
||||
str, int, float, bool, None, typing.Dict[str, "JSON"], typing.List["JSON"]
|
||||
] = typing.Union[
|
||||
|
@ -100,7 +102,10 @@ def get_all_truths(rich: bool = True, db: redis.Redis = Depends(get_db_factory()
|
|||
"""Retrieves all stored truths"""
|
||||
keys = db.keys()
|
||||
if rich is False:
|
||||
return keys
|
||||
return [
|
||||
{"id": key, "content": "", "author": "", "timestamp": 0, "extra": None}
|
||||
for key in keys
|
||||
]
|
||||
truths = [json.loads(db.get(key)) for key in keys]
|
||||
return truths
|
||||
|
||||
|
@ -108,12 +113,7 @@ def get_all_truths(rich: bool = True, db: redis.Redis = Depends(get_db_factory()
|
|||
@truth_router.get("/all", deprecated=True, response_model=list[TruthPayload])
|
||||
def get_all_truths_deprecated(response: JSONResponse, rich: bool = True, db: redis.Redis = Depends(get_db_factory())):
|
||||
"""DEPRECATED - USE get_all_truths INSTEAD"""
|
||||
keys = db.keys()
|
||||
if rich is False:
|
||||
return keys
|
||||
truths = [json.loads(db.get(key)) for key in keys]
|
||||
response.headers["X-Deprecated"] = "true"
|
||||
return truths
|
||||
return get_all_truths(rich, db)
|
||||
|
||||
|
||||
@truth_router.get("/{truth_id}", response_model=TruthPayload)
|
||||
|
|
Loading…
Reference in a new issue