Compute size of the indexed data only if explicitly requested to avoid heavy load on the DB

This commit is contained in:
sabaimran
2023-11-27 12:05:00 -08:00
parent eb5e3096e0
commit 6290b463f5
3 changed files with 25 additions and 3 deletions

View File

@@ -334,6 +334,18 @@ def get_default_config_data():
return constants.empty_config
@api.get("/config/index/size", response_model=Dict[str, int])
@requires(["authenticated"])
async def get_indexed_data_size(request: Request, common: CommonQueryParams):
user = request.user.object
indexed_data_size_in_mb = await sync_to_async(EntryAdapters.get_size_of_indexed_data_in_mb)(user)
return Response(
content=json.dumps({"indexed_data_size_in_mb": math.ceil(indexed_data_size_in_mb)}),
media_type="application/json",
status_code=200,
)
@api.get("/config/types", response_model=List[str])
@requires(["authenticated"])
def get_config_types(