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

change get_active_users return argument

parent 31da6c9c
......@@ -89,7 +89,7 @@ def predict_save_to_redis(user_profile, instance):
def router(device_id):
user_profile, not_exist = fetch_user_profile(device_id)
if not_exist:
if not_exist==1:
print('Sorry, we don\'t have you.')
else:
predict(user_profile)
......
......@@ -14,12 +14,14 @@ def get_active_users():
device_id_df = con_sql(sql)
if device_id_df.empty:
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
......@@ -28,11 +30,13 @@ def fetch_user_profile(device_id):
user_profile = con_sql(sql)
if user_profile.empty:
print("没有获取到该用户对应的city_id")
return {}, user_profile.empty
# 为了debug supervisor,修改了下面的return参数
return {1:2}, 1
else:
user_profile = user_profile.rename(columns={0:"device_id",1:"city_id"})
print("成功获取该用户对应的city_id")
user_profile_dict = {}
for i in user_profile.columns:
user_profile_dict[i] = user_profile.loc[0, i]
return user_profile_dict, user_profile.empty
# 为了debug supervisor,修改了下面的return参数
return user_profile_dict, "0"
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