Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
physical
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
alpha
physical
Commits
bab5269d
Commit
bab5269d
authored
Feb 11, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test score
parent
811bfabe
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
2 deletions
+74
-2
trans2es_data2es_parallel.py
trans2es/management/commands/trans2es_data2es_parallel.py
+74
-2
No files found.
trans2es/management/commands/trans2es_data2es_parallel.py
View file @
bab5269d
...
...
@@ -19,6 +19,13 @@ from libs.cache import redis_client
from
trans2es.models.face_user_contrast_similar
import
FaceUserContrastSimilar
import
json
from
search.utils.topic
import
TopicUtils
from
trans2es.models.pick_topic
import
PickTopic
from
trans2es.models.tag
import
TopicTag
,
Tag
from
trans2es.models.user_extra
import
UserExtra
from
trans2es.models.group
import
Group
from
trans2es.models.topic
import
Topic
,
ActionSumAboutTopic
class
Job
(
object
):
__es
=
None
...
...
@@ -97,7 +104,9 @@ class Command(BaseCommand):
make_option
(
'-s'
,
'--pks'
,
dest
=
'pks'
,
help
=
'specify sync pks, comma separated'
,
metavar
=
'PKS'
,
default
=
''
),
make_option
(
'--streaming-slicing'
,
dest
=
'streaming_slicing'
,
action
=
'store_true'
,
default
=
True
),
make_option
(
'--no-streaming-slicing'
,
dest
=
'streaming_slicing'
,
action
=
'store_false'
,
default
=
True
),
make_option
(
'-S'
,
'--sync_type'
,
dest
=
'sync_type'
,
help
=
'sync data to es'
,
metavar
=
'TYPE'
,
default
=
''
)
make_option
(
'-S'
,
'--sync_type'
,
dest
=
'sync_type'
,
help
=
'sync data to es'
,
metavar
=
'TYPE'
,
default
=
''
),
make_option
(
'-T'
,
'--test_score'
,
dest
=
'test_score'
,
help
=
'test_score'
,
metavar
=
'TYPE'
,
default
=
''
)
)
def
__sync_data_by_type
(
self
,
type_name
):
...
...
@@ -116,6 +125,68 @@ class Command(BaseCommand):
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
def
generate_topic_score_detail
(
self
):
try
:
topic_id_dict
=
TopicUtils
.
get_recommend_topic_ids
(
-
1
,
0
,
500
)
for
topic_id
in
topic_id_dict
:
offline_score
=
0.0
user_is_shadow
=
False
topic_sql_item
=
Topic
.
objects
.
filter
(
id
=
topic_id
)
user_is_recommend
=
0.0
# 是否官方推荐用户
user_query_results
=
UserExtra
.
objects
.
filter
(
user_id
=
topic_sql_item
[
0
]
.
user_id
)
if
user_query_results
.
count
()
>
0
:
if
user_query_results
[
0
]
.
is_recommend
:
offline_score
+=
2.0
user_is_recommend
=
2.0
elif
user_query_results
[
0
]
.
is_shadow
:
user_is_shadow
=
True
group_is_recommend
=
0.0
# 是否官方推荐小组
if
topic_sql_item
[
0
]
.
group
and
topic_sql_item
[
0
]
.
group
.
is_recommend
:
offline_score
+=
4.0
group_is_recommend
=
4.0
topic_level_score
=
0.0
# 帖子等级
if
topic_sql_item
[
0
]
.
content_level
==
'5'
:
offline_score
+=
5.0
topic_level_score
=
5.0
elif
topic_sql_item
[
0
]
.
content_level
==
'4'
:
offline_score
+=
3.0
topic_level_score
=
3.0
elif
topic_sql_item
[
0
]
.
content_level
==
'3'
:
offline_score
+=
2.0
topic_level_score
=
2.0
exposure_count
=
ActionSumAboutTopic
.
objects
.
filter
(
topic_id
=
topic_id
,
data_type
=
1
)
.
count
()
click_count
=
ActionSumAboutTopic
.
objects
.
filter
(
topic_id
=
topic_id
,
data_type
=
2
)
.
count
()
uv_num
=
ActionSumAboutTopic
.
objects
.
filter
(
topic_id
=
topic_id
,
data_type
=
3
)
.
count
()
exposure_score
=
0.0
uv_score
=
0.0
if
exposure_count
>
0
:
offline_score
+=
click_count
/
exposure_count
exposure_score
=
click_count
/
exposure_count
if
uv_num
>
0
:
offline_score
+=
(
topic_sql_item
[
0
]
.
vote_num
/
uv_num
+
topic_sql_item
[
0
]
.
reply_num
/
uv_num
)
uv_score
=
(
topic_sql_item
[
0
]
.
vote_num
/
uv_num
+
topic_sql_item
[
0
]
.
reply_num
/
uv_num
)
"""
1:马甲账号是否对总分降权?
"""
if
user_is_shadow
:
offline_score
=
offline_score
*
0.5
logging
.
info
(
"test_score,offline_score:
%
f,user_is_recommend:
%
f,group_is_recommend:
%
f,topic_level_score:
%
f,exposure_score:
%
f,uv_score:
%
f"
%
(
offline_score
,
user_is_recommend
,
group_is_recommend
,
topic_level_score
,
exposure_score
,
uv_score
))
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
def
handle
(
self
,
*
args
,
**
options
):
try
:
type_name_list
=
get_type_info_map
()
.
keys
()
...
...
@@ -129,6 +200,7 @@ class Command(BaseCommand):
if
len
(
options
[
"sync_type"
])
and
options
[
"sync_type"
]
==
"sync_data_to_es"
:
SyncDataToRedis
.
sync_face_similar_data_to_redis
()
if
len
(
options
[
"test_score"
]):
self
.
generate_topic_score_detail
()
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
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