diff --git a/webiste/app/db_class/db.py b/webiste/app/db_class/db.py index ecd1761..8c75980 100644 --- a/webiste/app/db_class/db.py +++ b/webiste/app/db_class/db.py @@ -27,6 +27,7 @@ class Session_db(db.Model): config_module=db.Column(db.String) result=db.Column(db.String) nb_errors = db.Column(db.Integer, index=True) + query_date = db.Column(db.DateTime, index=True) def to_json(self): return diff --git a/webiste/app/home.py b/webiste/app/home.py index 73db3e7..312d483 100644 --- a/webiste/app/home.py +++ b/webiste/app/home.py @@ -29,7 +29,12 @@ def query(sid): query_loc = s.query session=s if flag: - return render_template("query.html", query=query_loc, sid=sid, input_query=session.input_query, modules=json.loads(session.modules_list)) + return render_template("query.html", + query=query_loc, + sid=sid, + input_query=session.input_query, + modules=json.loads(session.modules_list), + query_date=session.query_date.strftime('%Y-%m-%d')) return render_template("404.html") diff --git a/webiste/app/home_core.py b/webiste/app/home_core.py index 75d0643..cab2403 100644 --- a/webiste/app/home_core.py +++ b/webiste/app/home_core.py @@ -139,5 +139,11 @@ def get_history(): histories = History.query.all() for history in histories: session = Session_db.query.get(history.session_id) - histories_list.append({"uuid": session.uuid, "query": session.query_enter, "modules": json.loads(session.modules_list), "input": session.input_query}) + histories_list.append({ + "uuid": session.uuid, + "query": session.query_enter, + "modules": json.loads(session.modules_list), + "input": session.input_query, + "query_date": session.query_date.strftime('%Y-%m-%d') + }) return histories_list diff --git a/webiste/app/session.py b/webiste/app/session.py index 1b99e49..b1bee96 100644 --- a/webiste/app/session.py +++ b/webiste/app/session.py @@ -1,3 +1,4 @@ +import datetime import json from queue import Queue from threading import Thread @@ -25,6 +26,7 @@ class Session_class: self.modules_list = request_json["modules"] self.nb_errors = 0 self.config_module = self.config_module_setter(request_json) + self.query_date = datetime.datetime.now(tz=datetime.timezone.utc) def config_module_setter(self, request_json): @@ -128,7 +130,8 @@ class Session_class: input_query=self.input_query, config_module=json.dumps(self.config_module), result=json.dumps(self.result), - nb_errors=self.nb_errors + nb_errors=self.nb_errors, + query_date=self.query_date ) db.session.add(s) db.session.commit() diff --git a/webiste/app/templates/history.html b/webiste/app/templates/history.html index 9fb1903..92b0cb0 100644 --- a/webiste/app/templates/history.html +++ b/webiste/app/templates/history.html @@ -25,6 +25,12 @@
+ + +
+
+ [[h.query_date]] +
diff --git a/webiste/app/templates/query.html b/webiste/app/templates/query.html index 7536334..d1f04b7 100644 --- a/webiste/app/templates/query.html +++ b/webiste/app/templates/query.html @@ -37,6 +37,10 @@ {%for module in modules%} {{module}}, {%endfor%} +
+
+ {{query_date}} +
@@ -125,7 +129,6 @@ // Button Stop pressed if (data['stopped']){ status_site.value = 'Stopped ! ' + sum + ' Success. ' + data["nb_errors"] + ' Errors. ' + data['complete'] + ' Total.' - console.log(data['complete'] - data["nb_errors"]); // Display result of the search }else{ status_site.value = sum + ' Success. ' + data["nb_errors"] + ' Errors. ' + data['complete'] + ' Total.' diff --git a/webiste/migrations/versions/91f830996ff4_.py b/webiste/migrations/versions/91f830996ff4_.py new file mode 100644 index 0000000..30f0f2a --- /dev/null +++ b/webiste/migrations/versions/91f830996ff4_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: 91f830996ff4 +Revises: d6f8bfc9d454 +Create Date: 2024-02-09 09:51:11.639862 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '91f830996ff4' +down_revision = 'd6f8bfc9d454' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('session_db', schema=None) as batch_op: + batch_op.add_column(sa.Column('query_date', sa.DateTime(), nullable=True)) + batch_op.create_index(batch_op.f('ix_session_db_query_date'), ['query_date'], unique=False) + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('session_db', schema=None) as batch_op: + batch_op.drop_index(batch_op.f('ix_session_db_query_date')) + batch_op.drop_column('query_date') + + # ### end Alembic commands ###