class Comments(db.Model): __tablename__ = 'comments' commID = db.Column(db.Integer, primary_key=True, autoincrement=True) cust_email = db.Column(db.String(50)) ticketID = db.Column(db.Integer) comm_datetime = db.Column(db.String(10)) comm_text = db.Column(db.Text)
class AccountModel(db.Model): """A model that reprsents a row in the cluster info table.""" __tablename__ = "account" account_id = db.Column(db.Integer, primary_key=True) last_updated_time = db.Column(db.DateTime) @staticmethod def get_total_accounts(): """Get the total number of records of this object.""" return db.session.query(func.count(AccountModel.account_id)).scalar()
class EmployeeLogin(db.Model): """ agent `login` table creation. This table will only hold the username & password for logging into Flask-Admin views for employees """ # Name of the table __tablename__ = 'login' adminID = db.Column(db.Integer, primary_key=True, autoincrement=True) username = db.Column(db.String(4), primary_key=True) password = db.Column(db.String(60))
class Tickets(db.Model): """ `tickets` table creation with a relationship between `department` and `customers` tables: - Create a one-to-one relationship on `tix_dept` inside of the `tickets` table and `deptID` inside of the `department` table - Create a one-to-many relationship on `custID` in the `tickets` table and the `customers` table. """ # Name of the table __tablename__ = 'tickets' ticketID = db.Column(db.Integer, nullable=False, primary_key=True, autoincrement=True, unique=True) custID = db.Column(db.Integer, db.ForeignKey('customers.custID')) tix_dept = db.Column(db.Integer, db.ForeignKey('department.deptID')) tix_severity = db.Column(db.String(2), nullable=False) tix_msg = db.Column(db.String(500), nullable=False) tix_status = db.Column(db.String(10), nullable=False) tix_recv_date = db.Column(db.String(20), nullable=False) tix_recv_time = db.Column(db.Integer, nullable=False) # define relationship between `tickets` table and these 2 tables department = db.relationship('Departments') customer = db.relationship('Customers')
class Customers(db.Model): """ `customers` table creation """ # Name of the table __tablename__ = 'customers' custID = db.Column(db.Integer, primary_key=True, autoincrement=True) cust_f_name = db.Column(db.String(30), nullable=False) cust_l_name = db.Column(db.String(30), nullable=False) cust_email = db.Column(db.String(60), nullable=False) cust_phone = db.Column(db.Integer, nullable=False) def __str__(self): """ method is used to display the `cust_f_name` instead of the actual object memory location :return: cust_f_name string """ return self.cust_f_name
class Departments(db.Model): """ `department` table creation """ # Name of the table __tablename__ = 'department' deptID = db.Column(db.Integer, primary_key=True, autoincrement=True, unique=True) dept_name = db.Column(db.String(40), nullable=False) dept_empl = db.Column(db.String(40), nullable=False) dept_empl_phone = db.Column(db.Integer, nullable=False) def __str__(self): """ method is used to display the `dept_name` instead of the actual object memory location :return: dept_name string """ return self.dept_name
class ClusterWorkloadInfoModel(db.Model): """A model that reprsents a row in the cluster info table.""" __tablename__ = "cluster_detail" cluster_id = db.Column(UUID(as_uuid=True), primary_key=True, unique=True) account_id = db.Column(db.Integer(), db.ForeignKey("account.account_id")) # 90 day usage. cpu_capacity_90 = db.Column(db.Float(asdecimal=True, decimal_return_scale=2)) cpu_utilization_percentage_90 = db.Column(db.Float(asdecimal=True, decimal_return_scale=2)) memory_capacity_90 = db.Column(db.Float(asdecimal=True, decimal_return_scale=2)) memory_utilization_percentage_90 = db.Column(db.Float(asdecimal=True, decimal_return_scale=2)) category_90 = db.Column(db.String(10)) # 180 day usage. cpu_capacity_180 = db.Column(db.Float(asdecimal=True, decimal_return_scale=2)) cpu_utilization_percentage_180 = db.Column(db.Float(asdecimal=True, decimal_return_scale=2)) memory_capacity_180 = db.Column(db.Float(asdecimal=True, decimal_return_scale=2)) memory_utilization_percentage_180 = db.Column(db.Float(asdecimal=True, decimal_return_scale=2)) category_180 = db.Column(db.String(10)) # 270 day usage. cpu_capacity_270 = db.Column(db.Float(asdecimal=True, decimal_return_scale=2)) cpu_utilization_percentage_270 = db.Column(db.Float(asdecimal=True, decimal_return_scale=2)) memory_capacity_270 = db.Column(db.Float(asdecimal=True, decimal_return_scale=2)) memory_utilization_percentage_270 = db.Column(db.Float(asdecimal=True, decimal_return_scale=2)) category_270 = db.Column(db.String(10)) # subscription info is_trail = db.Column(db.Boolean()) is_expiring_trial = db.Column(db.Boolean()) # lifetime cluster_age = db.Column(db.Integer()) cluster_last_reported = db.Column(db.DateTime) # audit info created_time = db.Column(db.DateTime) last_updated_time = db.Column(db.DateTime) @classmethod def get_total_count(cls, accounts): """Get the total number of records of this object.""" return cls.query.filter(cls.account_id.in_(accounts)).count()
class ThirukuralModel(db.Model): __tablename__ = 'kural' id = db.Column(db.Integer, primary_key=True, autoincrement=True) Number = db.Column(db.String()) Line1 = db.Column(db.String()) Line2 = db.Column(db.String()) Translation = db.Column(db.String()) couplet = db.Column(db.String()) mv = db.Column(db.String()) sp = db.Column(db.String()) mk = db.Column(db.String()) explanation = db.Column(db.String()) transliteration1 = db.Column(db.String()) transliteration2 = db.Column(db.String()) def __init__(self, Number, Line1, Line2): self.Number = Number self.Line1 = Line1 self.Line2 = Line2 def __repr__(self): return f"<Kural {self.Number}>"