Added only_ids to GET /saves
This commit is contained in:
parent
ce768d895d
commit
14d1ba9fa7
@ -14,8 +14,8 @@ from starlette.status import HTTP_204_NO_CONTENT, HTTP_403_FORBIDDEN, HTTP_404_N
|
|||||||
from modules.utils import configGet, zip_saves
|
from modules.utils import configGet, zip_saves
|
||||||
|
|
||||||
|
|
||||||
@app.get("/saves", response_class=UJSONResponse, response_model=Dict[str, StardewSave], description="Get all available game saves")
|
@app.get("/saves", response_class=UJSONResponse, response_model=Union[List[Dict[str, StardewSave]], List[int]], description="Get all available game saves")
|
||||||
async def saves_get(device: Union[str, None] = None, version: Union[str, None] = None, apikey: APIKey = Depends(get_api_key)):
|
async def saves_get(device: Union[str, None] = None, version: Union[str, None] = None, only_ids: bool = False, apikey: APIKey = Depends(get_api_key)):
|
||||||
|
|
||||||
user = user_by_key(apikey)
|
user = user_by_key(apikey)
|
||||||
|
|
||||||
@ -34,6 +34,11 @@ async def saves_get(device: Union[str, None] = None, version: Union[str, None] =
|
|||||||
|
|
||||||
output = []
|
output = []
|
||||||
|
|
||||||
|
if only_ids is True:
|
||||||
|
for entry in saves_entries:
|
||||||
|
if entry["id"] not in output:
|
||||||
|
output.append(entry["id"])
|
||||||
|
else:
|
||||||
for entry in saves_entries:
|
for entry in saves_entries:
|
||||||
out_entry = entry
|
out_entry = entry
|
||||||
del out_entry["_id"]
|
del out_entry["_id"]
|
||||||
|
Loading…
Reference in New Issue
Block a user