Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
ffm-baseline
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ML
ffm-baseline
Commits
cc482f19
Commit
cc482f19
authored
Aug 13, 2018
by
张彦钊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change get_active_users return argument
parent
31da6c9c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
3 deletions
+7
-3
predictDiary.py
predictDiary.py
+1
-1
userProfile.py
userProfile.py
+6
-2
No files found.
predictDiary.py
View file @
cc482f19
...
@@ -89,7 +89,7 @@ def predict_save_to_redis(user_profile, instance):
...
@@ -89,7 +89,7 @@ def predict_save_to_redis(user_profile, instance):
def
router
(
device_id
):
def
router
(
device_id
):
user_profile
,
not_exist
=
fetch_user_profile
(
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.'
)
print
(
'Sorry, we don
\'
t have you.'
)
else
:
else
:
predict
(
user_profile
)
predict
(
user_profile
)
...
...
userProfile.py
View file @
cc482f19
...
@@ -14,12 +14,14 @@ def get_active_users():
...
@@ -14,12 +14,14 @@ def get_active_users():
device_id_df
=
con_sql
(
sql
)
device_id_df
=
con_sql
(
sql
)
if
device_id_df
.
empty
:
if
device_id_df
.
empty
:
print
(
"当下这一分钟没有活跃用户,不需要预测"
)
print
(
"当下这一分钟没有活跃用户,不需要预测"
)
# 为了debug supervisor,修改了下面的return参数
return
1
,[
1
,
2
]
return
1
,[
1
,
2
]
else
:
else
:
device_id_list
=
device_id_df
[
0
]
.
values
.
tolist
()
device_id_list
=
device_id_df
[
0
]
.
values
.
tolist
()
# 对device_id 进行去重
# 对device_id 进行去重
device_id_list
=
list
(
set
(
device_id_list
))
device_id_list
=
list
(
set
(
device_id_list
))
print
(
"成功获取当下一分钟内活跃用户"
)
print
(
"成功获取当下一分钟内活跃用户"
)
# 为了debug supervisor,修改了下面的return参数
return
"0"
,
device_id_list
return
"0"
,
device_id_list
...
@@ -28,11 +30,13 @@ def fetch_user_profile(device_id):
...
@@ -28,11 +30,13 @@ def fetch_user_profile(device_id):
user_profile
=
con_sql
(
sql
)
user_profile
=
con_sql
(
sql
)
if
user_profile
.
empty
:
if
user_profile
.
empty
:
print
(
"没有获取到该用户对应的city_id"
)
print
(
"没有获取到该用户对应的city_id"
)
return
{},
user_profile
.
empty
# 为了debug supervisor,修改了下面的return参数
return
{
1
:
2
},
1
else
:
else
:
user_profile
=
user_profile
.
rename
(
columns
=
{
0
:
"device_id"
,
1
:
"city_id"
})
user_profile
=
user_profile
.
rename
(
columns
=
{
0
:
"device_id"
,
1
:
"city_id"
})
print
(
"成功获取该用户对应的city_id"
)
print
(
"成功获取该用户对应的city_id"
)
user_profile_dict
=
{}
user_profile_dict
=
{}
for
i
in
user_profile
.
columns
:
for
i
in
user_profile
.
columns
:
user_profile_dict
[
i
]
=
user_profile
.
loc
[
0
,
i
]
user_profile_dict
[
i
]
=
user_profile
.
loc
[
0
,
i
]
return
user_profile_dict
,
user_profile
.
empty
# 为了debug supervisor,修改了下面的return参数
return
user_profile_dict
,
"0"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment