Commit eeae786a authored by 张彦钊's avatar 张彦钊

add codes in test py file

parent a60bd8b6
...@@ -11,12 +11,26 @@ def con_sql(sql): ...@@ -11,12 +11,26 @@ def con_sql(sql):
db.close() db.close()
return df return df
if __name__ == "__main__": # 获取当下一分钟内活跃用户
while True: def get_active_users():
now = datetime.now() now = datetime.now()
now_start = str(now)[:16] + ":00" now_start = str(now)[:16] + ":00"
now_end = str(now)[:16] + ":59" now_end = str(now)[:16] + ":59"
sql = "select device_id from user_active_time " \ sql = "select device_id from user_active_time " \
"where active_time <= '{}' and active_time >= '{}'".format(now_end, now_start) "where active_time <= '{}' and active_time >= '{}'".format(now_end,now_start)
df = con_sql(sql) device_id_df = con_sql(sql)
print(df.head(1)) if device_id_df.empty:
\ No newline at end of file print("当下这一分钟没有活跃用户,不需要预测")
# 为了debug supervisor,修改了下面的return参数
return 1,[1,2]
else:
device_id_list = device_id_df[0].values.tolist()
# 对device_id 进行去重
device_id_list = list(set(device_id_list))
print("成功获取当下一分钟内活跃用户")
# 为了debug supervisor,修改了下面的return参数
return "0",device_id_list
if __name__ == "__main__":
while True:
get_active_users()
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