Skip to content

Commit

Permalink
chg: [website] query date
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidCruciani committed Feb 9, 2024
1 parent caf3c6f commit bbb698d
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 4 deletions.
1 change: 1 addition & 0 deletions webiste/app/db_class/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion webiste/app/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")


Expand Down
8 changes: 7 additions & 1 deletion webiste/app/home_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 4 additions & 1 deletion webiste/app/session.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import datetime
import json
from queue import Queue
from threading import Thread
Expand Down Expand Up @@ -25,6 +26,7 @@ def __init__(self, request_json) -> None:
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):
Expand Down Expand Up @@ -128,7 +130,8 @@ def save_info(self):
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()
Expand Down
6 changes: 6 additions & 0 deletions webiste/app/templates/history.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ <h5 class="mb-1">[[key+1]]- [[h.query]]</h5>
<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>
Expand Down
5 changes: 4 additions & 1 deletion webiste/app/templates/query.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ <h4>Modules:</h4>
{%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>

Expand Down Expand Up @@ -125,7 +129,6 @@ <h2 class="accordion-header">
// 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.'
Expand Down
34 changes: 34 additions & 0 deletions webiste/migrations/versions/91f830996ff4_.py
Original file line number Diff line number Diff line change
@@ -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 ###

0 comments on commit bbb698d

Please sign in to comment.