diff options
author | Alexander_Kabui | 2024-08-29 10:09:24 +0300 |
---|---|---|
committer | Alexander_Kabui | 2024-08-29 10:09:24 +0300 |
commit | c32378420d58d6770045cf8d2025dabccb4d1492 (patch) | |
tree | 3953ef227eec2e62ebad5966d9a4845bc4b4fbc1 /gn3/api | |
parent | 231cbd69ed5292451b976091e117d819e5466b30 (diff) | |
download | genenetwork3-c32378420d58d6770045cf8d2025dabccb4d1492.tar.gz |
Use correct http method `Delete` for search history.
Diffstat (limited to 'gn3/api')
-rw-r--r-- | gn3/api/llm.py | 7 |
1 files 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=?""", |