From c32378420d58d6770045cf8d2025dabccb4d1492 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Thu, 29 Aug 2024 10:09:24 +0300 Subject: Use correct http method `Delete` for search history. --- gn3/api/llm.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gn3/api/llm.py b/gn3/api/llm.py index d56a3d2..a94badd 100644 --- a/gn3/api/llm.py +++ b/gn3/api/llm.py @@ -86,21 +86,22 @@ def rate_queries(task_id): }, 200 -@gnqa.route("/history", methods=["GET", "POST"]) +@gnqa.route("/history", methods=["GET", "DELETE"]) @require_oauth("profile user") def fetch_prev_history(): """Api endpoint to fetch GNQA previous search.""" with (require_oauth.acquire("profile user") as token, db.connection(current_app.config["LLM_DB_PATH"]) as conn): cursor = conn.cursor() - if request.method == "POST": + if request.method == "DELETE": task_ids = list(request.json.values()) query = """DELETE FROM history WHERE task_id IN ({}) and user_id=?""".format(",".join("?" * len(task_ids))) cursor.execute(query, (*task_ids, str(token.user.user_id),)) return jsonify({}) - if request.args.get("search_term"): + elif (request.method == "GET" and + request.args.get("search_term")): cursor.execute( """SELECT results from history Where task_id=? and user_id=?""", -- cgit v1.2.3