From 22a1517e71ff6058090596498b9e829fb4e19664 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Fri, 24 May 2024 17:34:59 +0300 Subject: Add created_at timestamp for Rating table. --- gn3/api/llm.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'gn3') diff --git a/gn3/api/llm.py b/gn3/api/llm.py index 5924f12..ab33c7a 100644 --- a/gn3/api/llm.py +++ b/gn3/api/llm.py @@ -1,5 +1,6 @@ """Api endpoints for gnqa""" import json +from datetime import datetime, timezone from flask import Blueprint from flask import current_app from flask import jsonify @@ -69,15 +70,17 @@ def rate_queries(task_id): query TEXT NOT NULL, answer TEXT NOT NULL, weight INTEGER NOT NULL DEFAULT 0, - task_id TEXT NOT NULL UNIQUE + task_id TEXT NOT NULL UNIQUE, + created_at TIMESTAMP )""" cursor.execute(create_table) cursor.execute("""INSERT INTO Rating(user_id, query, - answer, weight, task_id) - VALUES(?,?,?,?,?) + answer, weight, task_id, created_at) + VALUES(?, ?, ?, ?, ?, ?) ON CONFLICT(task_id) DO UPDATE SET weight=excluded.weight - """, (str(user_id), query, answer, weight, task_id)) + """, (str(user_id), query, answer, weight, task_id, + datetime.now(timezone.utc))) return { "message": "You have successfully rated this query.Thank you!" }, 200 -- cgit v1.2.3