Commit edfe1e7a authored by suryakant's avatar suryakant

Trends Dashboard

parent afe24ad1
......@@ -4,7 +4,7 @@ from sqlalchemy.pool import NullPool
from scripts.configurations import postgres_details
from scripts.core.logging.application_logging import logger
from sqlalchemy_utils import create_database, database_exists
from scripts.core.schemas.postgres.postgres_tables import TrendsAsyncTable
from scripts.core.schemas.postgres.postgres_tables import TrendsMasterTable
from scripts.core.exception.app_exceptions import ErrorMessages, GeneralException
......@@ -22,10 +22,10 @@ def database_init():
if not database_exists(engine.url):
create_database(engine.url)
TrendsAsyncTable.__table__.create(bind=engine, checkfirst=True)
TrendsMasterTable.__table__.create(bind=engine, checkfirst=True)
logger.info("Tables initiation successful")
TrendsAsyncTable.index_name.create(bind=engine, checkfirst=True)
TrendsMasterTable.index_name.create(bind=engine, checkfirst=True)
# Creating database object for CRUD operation
database_obj = session_local()
......
......@@ -6,7 +6,7 @@ from scripts.core.schemas.postgres import TableObject
from scripts.core.logging.application_logging import logger
from scripts.core.exception.app_exceptions import GeneralException
from scripts.core.schemas.postgres.postgres_tables import \
TrendsAsyncTable
TrendsMasterTable
class TrendsDashboardHandler:
......@@ -26,7 +26,7 @@ class TrendsDashboardHandler:
max_score_json = {}
max_score_obj = TableObject(
db=db_init, table_name=TrendsAsyncTable
db=db_init, table_name=TrendsMasterTable
)
# max_score_query = fetch_max_score_downday_query(
# table=max_score_obj.table,
......
from sqlalchemy import VARCHAR, Column, Integer, Index, FLOAT
from sqlalchemy import VARCHAR, Column, Integer, Index, FLOAT, BOOLEAN
from datetime import datetime
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class TrendsAsyncTable(Base):
__tablename__ = "trends_dashboard_tbl"
class TrendsMasterTable(Base):
__tablename__ = "trends_master_tbl"
id = Column(Integer, primary_key=True)
id = Column(Integer, primary_key=True, autoincrement=True)
mapping_id = Column(VARCHAR, nullable=True)
department = Column(VARCHAR, nullable=True)
sub_menu = Column(VARCHAR, nullable=True)
form = Column(VARCHAR, nullable=True)
filter = Column(VARCHAR, nullable=True)
sub_filter = Column(VARCHAR, nullable=True)
parameter_name = Column(VARCHAR, nullable=True)
lower_limit = Column(FLOAT, nullable=True)
upper_limit = Column(FLOAT, nullable=True)
form_id = Column(VARCHAR, nullable=True)
line_id = Column(VARCHAR, nullable=True)
equipment_id = Column(VARCHAR, nullable=True)
parameter = Column(VARCHAR, nullable=True)
trend_captured = Column(BOOLEAN, nullable=True)
min = Column(FLOAT, nullable=True)
max = Column(FLOAT, nullable=True)
actual_value = Column(FLOAT, nullable=True)
recheck_value = Column(FLOAT, nullable=True)
index_name = Index('trends_async_index', id, department,
sub_menu, form, filter, sub_filter,
parameter_name)
index_name = Index('trends_master_indx', mapping_id, department,
sub_menu, form_id, line_id, equipment_id,
parameter)
class TrendsFormTable(Base):
__tablename__ = "trends_form_tbl"
id = Column(Integer, primary_key=True, autoincrement=True)
mapping_id = Column(VARCHAR, nullable=True)
value = Column(VARCHAR, nullable=True)
time = Column(datetime, nullable=True)
index_name = Index('trends_form_indx', mapping_id, time)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment