From 030a83aa4d78eeb2f39acaa24d1aa74863f3a0a2 Mon Sep 17 00:00:00 2001 From: DominikDoom Date: Tue, 26 Sep 2023 11:55:12 +0200 Subject: [PATCH] Use query parameter instead of path to fix wildcard subfolder issues --- javascript/_utils.js | 6 +++--- scripts/tag_autocomplete_helper.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/javascript/_utils.js b/javascript/_utils.js index c1ccb60..554e4f0 100644 --- a/javascript/_utils.js +++ b/javascript/_utils.js @@ -175,11 +175,11 @@ function tagBias(count, uses) { } // Call API endpoint to increase bias of tag in the database function increaseUseCount(tagName, type) { - postAPI(`tacapi/v1/increase-use-count/${tagName}?ttype=${type}`, null); + postAPI(`tacapi/v1/increase-use-count?tagname=${tagName}&ttype=${type}`, null); } // Get use count of tag from the database async function getUseCount(tagName, type) { - return (await fetchAPI(`tacapi/v1/get-use-count/${tagName}?ttype=${type}`, true, false))["result"]; + return (await fetchAPI(`tacapi/v1/get-use-count?tagname=${tagName}&ttype=${type}`, true, false))["result"]; } async function getUseCounts(tagNames, types) { return (await fetchAPI(`tacapi/v1/get-use-count-list?tags=${tagNames.join("&tags=")}&ttypes=${types.join("&ttypes=")}`))["result"]; @@ -188,7 +188,7 @@ async function getAllUseCounts() { return (await fetchAPI(`tacapi/v1/get-all-use-counts`))["result"]; } async function resetUseCount(tagName, type) { - putAPI(`tacapi/v1/reset-use-count/${tagName}?ttype=${type}`, null); + putAPI(`tacapi/v1/reset-use-count?tagname=${tagName}&ttype=${type}`, null); } // Sliding window function to get possible combination groups of an array diff --git a/scripts/tag_autocomplete_helper.py b/scripts/tag_autocomplete_helper.py index 42abfb5..1a28bb3 100644 --- a/scripts/tag_autocomplete_helper.py +++ b/scripts/tag_autocomplete_helper.py @@ -602,11 +602,11 @@ def api_tac(_: gr.Blocks, app: FastAPI): else: return JSONResponse({"error": "Database not initialized"}, status_code=500) - @app.post("/tacapi/v1/increase-use-count/{tagname}") + @app.post("/tacapi/v1/increase-use-count") async def increase_use_count(tagname: str, ttype: int): db_request(lambda: db.increase_tag_count(tagname, ttype)) - @app.get("/tacapi/v1/get-use-count/{tagname}") + @app.get("/tacapi/v1/get-use-count") async def get_use_count(tagname: str, ttype: int): return db_request(lambda: db.get_tag_count(tagname, ttype), get=True) @@ -614,7 +614,7 @@ def api_tac(_: gr.Blocks, app: FastAPI): async def get_use_count_list(tags: list[str] | None = Query(default=None), ttypes: list[int] | None = Query(default=None)): return db_request(lambda: list(db.get_tag_counts(tags, ttypes)), get=True) - @app.put("/tacapi/v1/reset-use-count/{tagname}") + @app.put("/tacapi/v1/reset-use-count") async def reset_use_count(tagname: str, ttype: int): db_request(lambda: db.reset_tag_count(tagname, ttype))