2024-02-15 12:01:36 +01:00
|
|
|
import json
|
2024-02-07 14:39:19 +01:00
|
|
|
from .. import db
|
|
|
|
|
|
|
|
|
|
|
|
class Module(db.Model):
|
|
|
|
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
|
|
|
name = db.Column(db.String, index=True, unique=True)
|
|
|
|
description = db.Column(db.String)
|
|
|
|
is_active = db.Column(db.Boolean, default=True)
|
|
|
|
request_on_query = db.Column(db.Boolean, default=False)
|
2024-02-12 15:33:47 +01:00
|
|
|
input_attr = db.Column(db.String)
|
2024-02-07 14:39:19 +01:00
|
|
|
|
|
|
|
def to_json(self):
|
|
|
|
json_dict = {
|
|
|
|
"id": self.id,
|
|
|
|
"name": self.name,
|
|
|
|
"description": self.description,
|
|
|
|
"is_active": self.is_active,
|
2024-02-12 15:33:47 +01:00
|
|
|
"request_on_query": self.request_on_query,
|
|
|
|
"input_attr": self.input_attr
|
2024-02-07 14:39:19 +01:00
|
|
|
}
|
|
|
|
return json_dict
|
|
|
|
|
|
|
|
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)
|
2024-02-08 15:31:36 +01:00
|
|
|
modules_list = db.Column(db.String)
|
2024-02-07 14:39:19 +01:00
|
|
|
query_enter = db.Column(db.String)
|
|
|
|
input_query = db.Column(db.String)
|
|
|
|
config_module=db.Column(db.String)
|
|
|
|
result=db.Column(db.String)
|
|
|
|
nb_errors = db.Column(db.Integer, index=True)
|
2024-02-09 11:13:14 +01:00
|
|
|
query_date = db.Column(db.DateTime, index=True)
|
2024-02-07 14:39:19 +01:00
|
|
|
|
|
|
|
def to_json(self):
|
2024-02-15 12:01:36 +01:00
|
|
|
json_dict = {
|
|
|
|
"id": self.id,
|
|
|
|
"uuid": self.uuid,
|
|
|
|
"modules": json.loads(self.modules_list),
|
|
|
|
"query_enter": self.query_enter,
|
|
|
|
"input_query": self.input_query,
|
|
|
|
"config_module": json.loads(self.config_module),
|
|
|
|
"result": json.loads(self.result),
|
|
|
|
"nb_errors": self.nb_errors,
|
|
|
|
"query_date": self.query_date.strftime('%Y-%m-%d')
|
|
|
|
}
|
|
|
|
return json_dict
|
|
|
|
|
|
|
|
def history_json(self):
|
|
|
|
json_dict = {
|
|
|
|
"uuid": self.uuid,
|
|
|
|
"modules": json.loads(self.modules_list),
|
|
|
|
"query": self.query_enter,
|
|
|
|
"input": self.input_query,
|
|
|
|
"query_date": self.query_date.strftime('%Y-%m-%d')
|
|
|
|
}
|
|
|
|
return json_dict
|
2024-02-07 14:39:19 +01:00
|
|
|
|
|
|
|
|
|
|
|
class History(db.Model):
|
|
|
|
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
|
|
|
session_id = db.Column(db.Integer, index=True)
|
|
|
|
|
2024-02-15 12:01:36 +01:00
|
|
|
class History_Tree(db.Model):
|
|
|
|
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
|
|
|
session_uuid = db.Column(db.String(36), index=True)
|
|
|
|
tree = db.Column(db.String)
|
2024-02-07 14:39:19 +01:00
|
|
|
|
|
|
|
class Config(db.Model):
|
|
|
|
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
|
|
|
name = db.Column(db.String, index=True, unique=True)
|
|
|
|
|
|
|
|
class Module_Config(db.Model):
|
|
|
|
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
|
|
|
|
module_id = db.Column(db.Integer, index=True)
|
|
|
|
config_id = db.Column(db.Integer, index=True)
|
|
|
|
value = db.Column(db.String, index=True)
|
|
|
|
|