diff --git a/bi/vas_yoy_flow.py b/bi/vas_yoy_flow.py index 1a51490..c8fea3b 100644 --- a/bi/vas_yoy_flow.py +++ b/bi/vas_yoy_flow.py @@ -32,17 +32,21 @@ class S: return safe_get_int(rows[0], "flow") return 0 + def insert_flow(self, ptime, flow): + sql = '''insert into vas_yoy_flow (ptime, flow) values ({}, {})'''.format(ptime, flow) + return self.mysql_db_bi.exec(sql, ()) + def proc(self): time_now = int(time.time()) zero_time = get_today_zero_time() - 86400 last_time = self.get_last_ptime() - last_time = get_today_zero_time() - 86400 - while last_time <= get_today_zero_time(): next_time = last_time + 300 flow = self.get_flow(zero_time, next_time) + self.insert_flow(get_time_str_by_ts(next_time), flow) print(get_time_str_by_ts(next_time), flow) + last_time += 300 time.sleep(0.5)