Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
gm_strategy_cvr
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rank
gm_strategy_cvr
Commits
81986785
Commit
81986785
authored
Jul 23, 2020
by
赵威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get result
parent
39b08cc5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
2 deletions
+42
-2
portrait.py
src/utils/portrait.py
+42
-2
No files found.
src/utils/portrait.py
View file @
81986785
import
datetime
import
datetime
import
json
import
json
import
random
import
random
from
itertools
import
chain
,
zip_longest
from
.cache
import
redis_client2
,
redis_client4
from
.cache
import
redis_client2
,
redis_client4
# merge_lists([1, 2], [3, 5, 6, 7], [4])
# [1, 3, 4, 2, 5, 6, 7]
def
merge_lists
(
*
lol
):
a
=
zip_longest
(
*
lol
)
return
[
i
for
i
in
chain
(
*
a
)
if
i
is
not
None
]
def
get_n_unread_data_from_ids
(
data
,
size
,
read_lst
):
def
get_n_unread_data_from_ids
(
data
,
size
,
read_lst
):
"""
"""
data: ['852170', '864084', '231589']
data: ['852170', '864084', '231589']
...
@@ -33,6 +41,34 @@ def get_before_5_days_date():
...
@@ -33,6 +41,34 @@ def get_before_5_days_date():
return
[
getdate
(
i
)
for
i
in
range
(
5
)]
return
[
getdate
(
i
)
for
i
in
range
(
5
)]
def
remove_read_with_size
(
lol
,
content_type
,
read_list
,
size
=
500
):
"""
content_type: diary, tractate, answer
diary, tractate: [[15358970, 16999710, 16569184, 16457012, 16424738], [17213175, 17203529, 16196387, 15597816, 16715016]]
answer [[['78937', 25449], ['50691', 19437]], [['78937', 25449], ['50691', 19437]]]
"""
read
=
set
(
read_list
)
res
=
[]
for
i
in
lol
:
tmp
=
[]
if
(
content_type
in
[
"diary"
,
"tractate"
]):
for
id
in
i
:
if
len
(
tmp
)
>=
size
:
break
if
id
not
in
read
:
tmp
.
append
(
id
)
res
.
append
(
tmp
)
else
:
for
(
id_str
,
question_id
)
in
i
:
id
=
int
(
id_str
)
if
len
(
tmp
)
>=
size
:
break
if
id
not
in
read
:
tmp
.
append
([
id_str
,
question_id
])
res
.
append
(
tmp
)
return
res
def
_user_portrait_tag3_get_candidate_key
(
device_id
,
content_type
,
latest
=
False
):
def
_user_portrait_tag3_get_candidate_key
(
device_id
,
content_type
,
latest
=
False
):
"""
"""
content_type: diary, tractate, answer
content_type: diary, tractate, answer
...
@@ -79,6 +115,10 @@ def user_portrait_tag3_get_candidate_unread_list(device_id, content_type):
...
@@ -79,6 +115,10 @@ def user_portrait_tag3_get_candidate_unread_list(device_id, content_type):
content_type: diary
content_type: diary
return: []
return: []
"""
"""
queue
=
[]
read_list
,
_
=
get_user_portrait_tag3_read_v2
(
device_id
,
content_type
)
read_list
,
_
=
get_user_portrait_tag3_read_v2
(
device_id
,
content_type
)
candidate_list
=
list
(
user_portrait_tag3_get_candidate_dict
(
device_id
,
content_type
)
.
values
())
diary_dict
=
user_portrait_tag3_get_candidate_dict
(
device_id
,
"diary"
)
return
get_n_unread_data_from_ids
(
candidate_list
,
500
,
read_list
)
if
diary_dict
:
lol
=
remove_read_with_size
(
diary_dict
.
values
(),
"diary"
,
read_list
,
500
)
queue
=
merge_lists
(
*
lol
)
return
queue
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