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
5be95f1e
Commit
5be95f1e
authored
Aug 07, 2020
by
赵威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
write data to es
parent
0202312e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
8 deletions
+31
-8
tag3_portrait_to_es.py
eda/smart_rank/tag3_portrait_to_es.py
+31
-8
No files found.
eda/smart_rank/tag3_portrait_to_es.py
View file @
5be95f1e
...
...
@@ -4,7 +4,7 @@ import pytz
import
redis
from
es_tool
import
es_insert_device_info
from
tool
import
get_user_portrait_tag3_from_redis
from
tool
import
(
get_user_portrait_tag3_from_redis
,
get_user_portrait_tag3_with_score
)
redis_client
=
redis
.
StrictRedis
.
from_url
(
"redis://:ReDis!GmTx*0aN6@172.16.40.133:6379"
)
redis_client2
=
redis
.
StrictRedis
.
from_url
(
"redis://:ReDis!GmTx*0aN9@172.16.40.173:6379"
)
...
...
@@ -40,21 +40,44 @@ def user_portrait_scan_info():
print
(
e
)
def
_dict_to_name_score
(
d
):
res
=
[]
for
(
k
,
v
)
in
d
.
items
():
res
.
append
({
"name"
:
k
,
"score"
:
v
})
return
res
def
write_to_es
(
device_id
):
body
=
get_user_portrait_tag3_from_redis
(
device_id
)
if
body
:
body
=
{}
d
=
get_user_portrait_tag3_with_score
(
device_id
)
if
d
:
first_demands_d
=
d
.
get
(
"first_demands"
,
{})
second_demands_d
=
d
.
get
(
"second_demands"
,
{})
first_positions_d
=
d
.
get
(
"first_positions"
,
{})
second_positions_d
=
d
.
get
(
"second_positions"
,
{})
first_solutions_d
=
d
.
get
(
"first_solutions"
,
{})
second_solutions_d
=
d
.
get
(
"second_solutions"
,
{})
projects_d
=
d
.
get
(
"projects"
,
{})
anecdote_tags
=
d
.
get
(
"anecdote_tags"
,
[])
body
[
"device_id"
]
=
device_id
body
[
"last_modified"
]
=
datetime
.
datetime
.
strftime
(
datetime
.
datetime
.
now
(
pytz
.
timezone
(
"Asia/Shanghai"
)),
"
%
Y-
%
m-
%
dT
%
H:
%
M:
%
S.
%
f"
)[:
-
7
]
+
"Z"
body
[
"city_cn"
]
=
""
body
[
"city_en"
]
=
""
body
[
"first_demands"
]
=
_dict_to_name_score
(
first_demands_d
)
body
[
"second_demands"
]
=
_dict_to_name_score
(
second_demands_d
)
body
[
"first_positions"
]
=
_dict_to_name_score
(
first_positions_d
)
body
[
"second_positions"
]
=
_dict_to_name_score
(
second_positions_d
)
body
[
"first_solutions"
]
=
_dict_to_name_score
(
first_solutions_d
)
body
[
"second_solutions"
]
=
_dict_to_name_score
(
second_solutions_d
)
body
[
"projects"
]
=
_dict_to_name_score
(
projects_d
)
body
[
"anecdote_tags"
]
=
anecdote_tags
es_insert_device_info
(
device_id
,
body
)
if
__name__
==
"__main__"
:
#
device_id = "androidid_a25a1129c0b38f7b"
#
write_to_es(device_id)
device_id
=
"androidid_a25a1129c0b38f7b"
write_to_es
(
device_id
)
user_portrait_scan_info
()
#
user_portrait_scan_info()
print
(
"done: "
+
str
(
datetime
.
datetime
.
now
()))
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