chg: [website] query date

pull/654/head
David Cruciani 2024-02-09 11:13:14 +01:00
parent caf3c6f3c1
commit bbb698d260
No known key found for this signature in database
GPG Key ID: 8690CDE1E3994B9B
7 changed files with 62 additions and 4 deletions

View File

@ -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

View File

@ -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")

View File

@ -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

View File

@ -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()

View File

@ -25,6 +25,12 @@
<div>
<template v-for="module in h.modules">[[module]],</template>
</div>
<div class="d-flex w-100 justify-content-between">
<div></div>
<small><i>[[h.query_date]]</i></small>
</div>
</a>
</div>
</template>

View File

@ -37,6 +37,10 @@
{%for module in modules%} {{module}}, {%endfor%}
</div>
</div>
<div class="d-flex w-100 justify-content-between">
<div></div>
<small><i>{{query_date}}</i></small>
</div>
</div>
</div>
@ -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.'

View File

@ -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 ###