Skip to content

Commit

Permalink
chg: [website] rename glob_query to modules_list
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidCruciani committed Feb 8, 2024
1 parent 0b73052 commit 4d0672f
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 12 deletions.
2 changes: 1 addition & 1 deletion webiste/app/db_class/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def to_json(self):
class Session_db(db.Model):
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
uuid = db.Column(db.String(36), index=True, unique=True)
glob_query = db.Column(db.String)
modules_list = db.Column(db.String)
query_enter = db.Column(db.String)
input_query = db.Column(db.String)
config_module=db.Column(db.String)
Expand Down
2 changes: 1 addition & 1 deletion webiste/app/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ 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.glob_query))
return render_template("query.html", query=query_loc, sid=sid, input_query=session.input_query, modules=json.loads(session.modules_list))
return render_template("404.html")


Expand Down
8 changes: 4 additions & 4 deletions webiste/app/home_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ def change_status_core(module_id):
##############

def get_status_db(session):
glob_query = json.loads(session.glob_query)
"""Return status of a session"""
modules_list = json.loads(session.modules_list)
result = json.loads(session.result)
return{
'id': session.uuid,
'total': len(glob_query),
'complete': len(glob_query),
'total': len(modules_list),
'complete': len(modules_list),
'remaining': 0,
'registered': len(result),
'stopped' : True,
Expand All @@ -139,5 +139,5 @@ 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.glob_query), "input": session.input_query})
histories_list.append({"uuid": session.uuid, "query": session.query_enter, "modules": json.loads(session.modules_list), "input": session.input_query})
return histories_list
12 changes: 6 additions & 6 deletions webiste/app/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ def __init__(self, request_json) -> None:
self.result = dict()
self.query = request_json["query"]
self.input_query = request_json["input"]
self.glob_query = self.expansion + self.hover
self.modules_list = request_json["modules"]
self.nb_errors = 0
self.config_module = self.config_module_setter(request_json)

def config_module_setter(self, request_json):
if request_json["config"]:
for query in self.glob_query:
for query in self.modules_list:
if not query in request_json["config"]:
request_json["config"][query] = {}
module = HomeModel.get_module_by_name(query)
Expand All @@ -41,9 +41,9 @@ def config_module_setter(self, request_json):

def start(self):
"""Start all worker"""
for i in range(len(self.glob_query)):
for i in range(len(self.modules_list)):
#need the index and the url in each queue item.
self.jobs.put((i, self.glob_query[i]))
self.jobs.put((i, self.modules_list[i]))
for _ in range(self.thread_count):
worker = Thread(target=self.process)
worker.daemon = True
Expand All @@ -55,7 +55,7 @@ def status(self):
if self.jobs.empty():
self.stop()

total = len(self.glob_query)
total = len(self.modules_list)
remaining = max(self.jobs.qsize(), len(self.threads))
complete = total - remaining
registered = len(self.result)
Expand Down Expand Up @@ -123,7 +123,7 @@ def get_result(self):
def save_info(self):
s = Session_db(
uuid=str(self.id),
glob_query=json.dumps(self.glob_query),
modules_list=json.dumps(self.modules_list),
query_enter=self.query,
input_query=self.input_query,
config_module=json.dumps(self.config_module),
Expand Down
34 changes: 34 additions & 0 deletions webiste/migrations/versions/d6f8bfc9d454_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""empty message
Revision ID: d6f8bfc9d454
Revises: c0e243696052
Create Date: 2024-02-08 15:23:46.714541
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'd6f8bfc9d454'
down_revision = 'c0e243696052'
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('modules_list', sa.String(), nullable=True))
batch_op.drop_column('glob_query')

# ### 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.add_column(sa.Column('glob_query', sa.VARCHAR(), nullable=True))
batch_op.drop_column('modules_list')

# ### end Alembic commands ###

0 comments on commit 4d0672f

Please sign in to comment.