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 fastapi.security import HTTPBasic, HTTPBasicCredentials
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
|
from symbol import return_stmt
|
||||||
|
|
||||||
JSON: typing.Union[
|
JSON: typing.Union[
|
||||||
str, int, float, bool, None, typing.Dict[str, "JSON"], typing.List["JSON"]
|
str, int, float, bool, None, typing.Dict[str, "JSON"], typing.List["JSON"]
|
||||||
] = typing.Union[
|
] = typing.Union[
|
||||||
|
@ -100,7 +102,10 @@ def get_all_truths(rich: bool = True, db: redis.Redis = Depends(get_db_factory()
|
||||||
"""Retrieves all stored truths"""
|
"""Retrieves all stored truths"""
|
||||||
keys = db.keys()
|
keys = db.keys()
|
||||||
if rich is False:
|
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]
|
truths = [json.loads(db.get(key)) for key in keys]
|
||||||
return truths
|
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])
|
@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())):
|
def get_all_truths_deprecated(response: JSONResponse, rich: bool = True, db: redis.Redis = Depends(get_db_factory())):
|
||||||
"""DEPRECATED - USE get_all_truths INSTEAD"""
|
"""DEPRECATED - USE get_all_truths INSTEAD"""
|
||||||
keys = db.keys()
|
return get_all_truths(rich, db)
|
||||||
if rich is False:
|
|
||||||
return keys
|
|
||||||
truths = [json.loads(db.get(key)) for key in keys]
|
|
||||||
response.headers["X-Deprecated"] = "true"
|
|
||||||
return truths
|
|
||||||
|
|
||||||
|
|
||||||
@truth_router.get("/{truth_id}", response_model=TruthPayload)
|
@truth_router.get("/{truth_id}", response_model=TruthPayload)
|
||||||
|
|
Loading…
Reference in a new issue