def plan_and_execute(self, analysis): for diff in analysis: update_plan = db_session.query(Plan).filter(Plan.id == diff[0]).one() # print("Plan:", diff) # Low demand, lower price if diff[1] < 0: if (update_plan.price > 2): update_plan.price += diff[1] // 10 db_session.commit() # High demand, higher price elif diff[1] > 0: update_plan.price += diff[1] // 10 db_session.commit()
def __init__(self): self.monitor = Monitor() self.analyzer = Analyer() self.planner = Planner() self.optimize_plan = db_session.query(Account_Policies).first()
def get_plan(self): try: return db_session.query(Account_Policies).first().maxmize_plan except: return -1
def task_count(self, task_number): return db_session.query( func.count(Task.id)).filter(Task.plan == task_number).one()[0]
def tasks(self): return db_session.query(Task.plan, func.count(Task.id)).group_by(Task.plan).all()
def total_tasks(self): return db_session.query(func.count(Task.id)).one()[0]