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
537ad1e3
Commit
537ad1e3
authored
Aug 05, 2020
by
赵威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
try get data
parent
7730892b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
1 deletion
+55
-1
tag3_portrait_to_es.py
eda/smart_rank/tag3_portrait_to_es.py
+54
-0
tool.py
eda/smart_rank/tool.py
+1
-1
No files found.
eda/smart_rank/tag3_portrait_to_es.py
0 → 100644
View file @
537ad1e3
import
datetime
import
pytz
import
redis
from
es_tool
import
es_insert_device_info
from
tool
import
get_user_portrait_tag3_from_redis
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"
)
redis_client3
=
redis
.
StrictRedis
.
from_url
(
"redis://:ReDis!GmTx*0aN12@172.16.40.164:6379"
)
redis_client4
=
redis
.
StrictRedis
.
from_url
(
"redis://:XfkMCCdWDIU
%
ls$h@172.16.50.145:6379"
)
def
user_portrait_scan_info
():
try
:
round
=
0
all_count
=
0
just_projects_count
=
0
portrait_no_candidates_count
=
0
keys
=
"doris:user_portrait:tag3:device_id:*"
cur
,
results
=
redis_client2
.
scan
(
0
,
keys
,
3000
)
while
cur
!=
0
:
round
+=
1
print
(
"round: "
+
str
(
round
))
cur
,
results
=
redis_client2
.
scan
(
cur
,
keys
,
3000
)
for
key
in
results
:
key
=
str
(
key
,
"utf-8"
)
device_id
=
key
.
split
(
":"
)[
-
1
]
all_count
+=
1
write_to_es
(
device_id
)
print
(
"all count: "
+
str
(
all_count
))
print
(
"just projects portrait: "
+
str
(
just_projects_count
))
print
(
"just portrait no candidates: "
+
str
(
portrait_no_candidates_count
))
print
(
"scan done "
+
str
(
datetime
.
datetime
.
now
()))
except
Exception
as
e
:
print
(
e
)
def
write_to_es
(
device_id
):
body
=
get_user_portrait_tag3_from_redis
(
device_id
)
if
body
:
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"
print
(
body
)
# es_insert_device_info(device_id, body)
if
__name__
==
"__main__"
:
device_id
=
"androidid_a25a1129c0b38f7b"
write_to_es
(
device_id
)
eda/smart_rank/tool.py
View file @
537ad1e3
...
...
@@ -517,7 +517,7 @@ def get_user_portrait_tag3_from_redis(device_id, limit_score=0):
portrait_key
=
"doris:user_portrait:tag3:device_id:"
+
str
(
device_id
)
redis_client
=
get_redis_client
()
if
redis_client
.
exists
(
portrait_key
):
user_portrait
=
json
.
loads
(
redis_client
.
get
(
portrait_key
))
user_portrait
=
json
.
loads
(
redis_client
.
get
(
portrait_key
)
.
decode
(
"utf-8"
)
)
first_demands
=
items_gt_score
(
user_portrait
.
get
(
"first_demands"
,
{}))
second_demands
=
items_gt_score
(
user_portrait
.
get
(
"second_demands"
,
{}))
first_solutions
=
items_gt_score
(
user_portrait
.
get
(
"first_solutions"
,
{}))
...
...
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