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
27b037ea
Commit
27b037ea
authored
May 20, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Revert "Merge branch 'test' into 'master'""
This reverts commit
a3b0c854
parent
d3d9138e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
86 additions
and
47 deletions
+86
-47
tasks.py
injection/data_sync/tasks.py
+11
-2
group.py
search/utils/group.py
+17
-18
topic.py
search/utils/topic.py
+0
-0
group.py
search/views/group.py
+20
-11
topic.py
search/views/topic.py
+0
-0
topic-high-star.json
trans2es/mapping/topic-high-star.json
+1
-0
topic-star-routing.json
trans2es/mapping/topic-star-routing.json
+1
-0
topic.json
trans2es/mapping/topic.json
+1
-0
user.json
trans2es/mapping/user.json
+1
-0
tag.py
trans2es/models/tag.py
+2
-0
topic.py
trans2es/models/topic.py
+12
-16
user.py
trans2es/models/user.py
+14
-0
topic_transfer.py
trans2es/utils/topic_transfer.py
+5
-0
user_transfer.py
trans2es/utils/user_transfer.py
+1
-0
No files found.
injection/data_sync/tasks.py
View file @
27b037ea
...
...
@@ -60,12 +60,21 @@ def sync_face_similar_data_to_redis():
item_list
=
list
()
for
item
in
similar_result_items
:
weight_score
=
int
(
item
.
similarity
*
100
)
item_list
.
append
(
{
"contrast_user_id"
:
item
.
contrast_user_id
,
"similarity"
:
item
.
similarity
"filter"
:{
"constant_score"
:{
"filter"
:{
"term"
:{
"user_id"
:
item
.
contrast_user_id
}
}
}
},
"weight"
:
weight_score
*
2
}
)
if
len
(
item_list
)
>=
100
:
break
redis_client
.
set
(
redis_key
,
json
.
dumps
(
item_list
))
logging
.
info
(
"participant_user_id:
%
d set data done!"
%
participant_user_id
)
...
...
search/utils/group.py
View file @
27b037ea
...
...
@@ -47,7 +47,7 @@ class GroupUtils(object):
return
{
"total_count"
:
0
,
"hits"
:
[]}
@classmethod
def
get_hot_pictorial_recommend_result_list
(
cls
,
offset
,
size
,
es_cli_obj
=
None
,
attention_tag_list
=
[]):
def
get_hot_pictorial_recommend_result_list
(
cls
,
offset
,
size
,
es_cli_obj
=
None
,
attention_tag_list
=
[]):
try
:
if
not
es_cli_obj
:
es_cli_obj
=
ESPerform
.
get_cli
()
...
...
@@ -55,10 +55,10 @@ class GroupUtils(object):
functions_list
=
list
()
for
tag_id
in
attention_tag_list
:
functions_list
.
append
({
"filter"
:{
"constant_score"
:{
"filter"
:{
"term"
:{
"filter"
:
{
"constant_score"
:
{
"filter"
:
{
"term"
:
{
"tag_id"
:
tag_id
}
}
...
...
@@ -67,7 +67,7 @@ class GroupUtils(object):
"weight"
:
20
})
if
len
(
functions_list
)
>=
20
:
if
len
(
functions_list
)
>=
20
:
break
functions_list
.
append
(
...
...
@@ -82,17 +82,17 @@ class GroupUtils(object):
}
)
q
=
{
"query"
:{
"function_score"
:{
"query"
:{
"bool"
:{
"filter"
:[
"query"
:
{
"function_score"
:
{
"query"
:
{
"bool"
:
{
"filter"
:
[
{
"term"
:
{
"is_online"
:
True
}},
{
"term"
:
{
"is_deleted"
:
False
}},
{
"term"
:
{
"effective"
:
True
}}
],
"must_not"
:[
{
"term"
:
{
"is_default"
:
1
}}
"must_not"
:
[
{
"term"
:
{
"is_default"
:
1
}}
]
}
},
...
...
@@ -116,16 +116,16 @@ class GroupUtils(object):
}
},
{
"_score"
:{
"_score"
:
{
"order"
:
"desc"
}
}
]
q
[
"_source"
]
=
{
"includes"
:[
"id"
]
"includes"
:
[
"id"
]
}
result_dict
=
ESPerform
.
get_search_results
(
es_cli_obj
,
"pictorial"
,
q
,
offset
,
size
)
result_dict
=
ESPerform
.
get_search_results
(
es_cli_obj
,
"pictorial"
,
q
,
offset
,
size
)
pictorial_ids_list
=
[]
if
len
(
result_dict
[
"hits"
])
>
0
:
...
...
@@ -153,7 +153,7 @@ class GroupUtils(object):
{
"term"
:
{
"is_online"
:
True
}},
{
"term"
:
{
"user_id"
:
user_id
}},
{
"term"
:
{
"is_deleted"
:
False
}},
{
"term"
:
{
"effective"
:
True
}}
{
"term"
:
{
"effective"
:
True
}}
]
}
}
...
...
@@ -171,7 +171,6 @@ class GroupUtils(object):
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
[]
@classmethod
def
get_pictorial_ids_by_aggs
(
cls
,
pictorial_ids_list
,
es_cli_obj
=
None
):
"""
...
...
search/utils/topic.py
View file @
27b037ea
This diff is collapsed.
Click to expand it.
search/views/group.py
View file @
27b037ea
...
...
@@ -10,6 +10,7 @@ from libs.es import ESPerform
from
search.utils.group
import
GroupUtils
from
search.utils.common
import
GroupSortTypes
from
libs.es
import
ESPerform
from
trans2es.models.pictorial
import
PictorialTopics
@bind
(
"physical/search/query_pictorial"
)
...
...
@@ -54,11 +55,12 @@ def pictorial_sort(user_id=-1, sort_type=GroupSortTypes.HOT_RECOMMEND, offset=0,
if
sort_type
==
GroupSortTypes
.
HOT_RECOMMEND
:
# 用户关注标签
attention_tag_list
=
list
()
if
user_id
>
0
:
if
user_id
>
0
:
redis_tag_data
=
redis_client
.
hget
(
"physical:linucb:register_user_tag_info"
,
user_id
)
attention_tag_list
=
json
.
loads
(
redis_tag_data
)
if
redis_tag_data
else
[]
pictorial_ids_list
=
GroupUtils
.
get_hot_pictorial_recommend_result_list
(
offset
,
size
,
es_cli_obj
,
attention_tag_list
)
pictorial_ids_list
=
GroupUtils
.
get_hot_pictorial_recommend_result_list
(
offset
,
size
,
es_cli_obj
,
attention_tag_list
)
return
{
"pictorial_recommend_ids"
:
pictorial_ids_list
}
elif
sort_type
==
GroupSortTypes
.
ATTENTION_RECOMMEND
:
...
...
@@ -173,6 +175,13 @@ def pictorial_topic(topic_id=-1, offset=0, size=10):
"term"
:
{
"is_deleted"
:
False
}
},
{
"range"
:
{
"topic_id_list"
:
{
"gte"
:
0
}
}
}]
}
}
...
...
@@ -209,7 +218,7 @@ def pictorial_topic(topic_id=-1, offset=0, size=10):
@bind
(
"physical/search/pictorial_topic_sort"
)
def
pictorial_topic_sort
(
pictorial_id
=-
1
,
offset
=
0
,
size
=
10
):
"""
:remark
小组排序,缺少:前1天发评论人数*x
:remark
画报排序 人气 部分
:param user_id:
:param sort_type:
:param offset:
...
...
@@ -221,33 +230,33 @@ def pictorial_topic_sort(pictorial_id=-1, offset=0, size=10):
user_id
=
-
1
q
=
{
"query"
:{
"bool"
:{
"must"
:[
{
"term"
:{
"pictorial_id"
:
pictorial_id
}},
"query"
:
{
"bool"
:
{
"must"
:
[
{
"term"
:
{
"pictorial_id"
:
pictorial_id
}},
{
"term"
:
{
"is_online"
:
True
}},
{
"term"
:
{
"is_deleted"
:
False
}},
]
}
},
"sort"
:[
"sort"
:
[
{
"total_vote_num"
:
{
"order"
:
"desc"
}},
{
"create_time"
:
{
"order"
:
"desc"
}}
]
}
pict_pictorial_ids_list
=
[]
pict_pictorial_ids_list
=
[]
# 获取es链接对象
es_cli_obj
=
ESPerform
.
get_cli
()
result_dict
=
ESPerform
.
get_search_results
(
es_cli_obj
,
"topic"
,
q
,
offset
,
size
)
logging
.
info
(
"get pictorial_topic_sort res:
%
s"
%
result_dict
)
logging
.
info
(
"get pictorial_topic_sort res:
%
s"
%
result_dict
)
for
item
in
result_dict
[
"hits"
]:
topic_id
=
item
[
"_source"
][
"id"
]
pict_pictorial_ids_list
.
append
(
topic_id
)
return
{
"pict_pictorial_ids_list"
:
pict_pictorial_ids_list
}
return
{
"pict_pictorial_ids_list"
:
pict_pictorial_ids_list
}
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
...
...
search/views/topic.py
View file @
27b037ea
This diff is collapsed.
Click to expand it.
trans2es/mapping/topic-high-star.json
View file @
27b037ea
...
...
@@ -17,6 +17,7 @@
"user_nick_name_pre"
:
{
"type"
:
"text"
,
"analyzer"
:
"keyword"
},
//不切词的用户名
"group_id"
:{
"type"
:
"long"
},
//所在组ID
"tag_list"
:{
"type"
:
"long"
},
//标签属性
"useful_tag_list"
:{
"type"
:
"long"
},
//有用标签属性
"edit_tag_list"
:{
"type"
:
"long"
},
//编辑标签
"tag_name_list"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_index"
},
"share_num"
:{
"type"
:
"long"
},
...
...
trans2es/mapping/topic-star-routing.json
View file @
27b037ea
...
...
@@ -16,6 +16,7 @@
"user_nick_name"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_index"
},
//帖子用户名
"user_nick_name_pre"
:
{
"type"
:
"text"
,
"analyzer"
:
"keyword"
},
//不切词的用户名
"group_id"
:{
"type"
:
"long"
},
//所在组ID
"useful_tag_list"
:{
"type"
:
"long"
},
//有用标签属性
"tag_list"
:{
"type"
:
"long"
},
//标签属性
"edit_tag_list"
:{
"type"
:
"long"
},
//编辑标签
"tag_name_list"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_index"
},
...
...
trans2es/mapping/topic.json
View file @
27b037ea
...
...
@@ -17,6 +17,7 @@
"user_nick_name_pre"
:
{
"type"
:
"text"
,
"analyzer"
:
"keyword"
},
//不切词的用户名
"group_id"
:{
"type"
:
"long"
},
//所在组ID
"tag_list"
:{
"type"
:
"long"
},
//标签属性
"useful_tag_list"
:{
"type"
:
"long"
},
//有用标签属性
"edit_tag_list"
:{
"type"
:
"long"
},
//编辑标签
"tag_name_list"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_index"
},
"share_num"
:{
"type"
:
"long"
},
...
...
trans2es/mapping/user.json
View file @
27b037ea
...
...
@@ -9,6 +9,7 @@
"is_online"
:{
"type"
:
"boolean"
},
//是否上线
"is_deleted"
:{
"type"
:
"boolean"
},
"tag_list"
:{
"type"
:
"long"
},
//标签属性
"useful_tag_list"
:{
"type"
:
"long"
},
//有用标签属性
"city_id"
:{
"type"
:
"text"
},
"country_id"
:{
"type"
:
"text"
},
"is_recommend"
:{
"type"
:
"boolean"
},
//是否运营推荐用户
...
...
trans2es/models/tag.py
View file @
27b037ea
...
...
@@ -20,6 +20,7 @@ class TopicTag(models.Model):
topic_id
=
models
.
IntegerField
(
verbose_name
=
u"帖子ID"
)
is_online
=
models
.
BooleanField
(
verbose_name
=
u"是否在线"
)
is_collection
=
models
.
IntegerField
(
verbose_name
=
u"是否编辑标签"
)
is_body_esthetics
=
models
.
IntegerField
(
verbose_name
=
u"是否有用标签"
)
class
AccountUserTag
(
models
.
Model
):
...
...
@@ -33,6 +34,7 @@ class AccountUserTag(models.Model):
is_deleted
=
models
.
BooleanField
(
verbose_name
=
u"是否删除"
)
create_time
=
models
.
DateTimeField
(
verbose_name
=
u'创建时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
update_time
=
models
.
DateTimeField
(
verbose_name
=
u'更新时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
is_body_esthetics
=
models
.
IntegerField
(
verbose_name
=
u"是否有用标签"
)
class
Tag
(
models
.
Model
):
...
...
trans2es/models/topic.py
View file @
27b037ea
...
...
@@ -191,6 +191,18 @@ class Topic(models.Model):
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
([],[])
def
get_topic_useful_tag_id_list
(
self
):
try
:
topic_useful_tag_id_list
=
list
()
tag_id_list
=
TopicTag
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
topic_id
=
self
.
id
,
is_online
=
True
,
is_body_esthetics
=
1
)
for
tag_item
in
tag_id_list
:
topic_useful_tag_id_list
.
append
(
tag_item
.
tag_id
)
return
topic_useful_tag_id_list
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
[]
def
get_tag_name_list
(
self
,
tag_id_list
):
try
:
tag_name_list
=
list
()
...
...
@@ -227,10 +239,6 @@ class Topic(models.Model):
elif
user_query_results
[
0
]
.
is_shadow
:
user_is_shadow
=
True
# 是否官方推荐小组
# if self.group and self.group.is_recommend:
# offline_score += 4.0
# 帖子等级
if
self
.
content_level
==
'5'
:
offline_score
+=
100.0
*
3
...
...
@@ -239,20 +247,8 @@ class Topic(models.Model):
elif
self
.
content_level
==
'6'
:
offline_score
+=
200.0
*
3
# is_excellent = self.judge_if_excellent_topic(self.id)
# if is_excellent:
# offline_score += 200.0
if
self
.
language_type
==
1
:
offline_score
+=
60.0
# exposure_count = ActionSumAboutTopic.objects.using(settings.SLAVE_DB_NAME).filter(topic_id=self.id, data_type=1).count()
# click_count = ActionSumAboutTopic.objects.using(settings.SLAVE_DB_NAME).filter(topic_id=self.id, data_type=2).count()
# uv_num = ActionSumAboutTopic.objects.using(settings.SLAVE_DB_NAME).filter(topic_id=self.id, data_type=3).count()
#
# if exposure_count > 0:
# offline_score += click_count / exposure_count
# if uv_num > 0:
# offline_score += (self.vote_num / uv_num + self.reply_num / uv_num)
"""
1:马甲账号是否对总分降权?
...
...
trans2es/models/user.py
View file @
27b037ea
...
...
@@ -189,3 +189,16 @@ class User(models.Model):
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
[]
def
get_user_useful_tag_id_list
(
self
):
try
:
user_useful_tag_id_list
=
list
()
query_results
=
AccountUserTag
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
user
=
self
.
user_id
,
is_body_esthetics
=
1
,
is_deleted
=
False
)
for
item
in
query_results
:
user_useful_tag_id_list
.
append
(
item
.
tag_id
)
return
user_useful_tag_id_list
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
[]
\ No newline at end of file
trans2es/utils/topic_transfer.py
View file @
27b037ea
...
...
@@ -75,6 +75,11 @@ class TopicTransfer(object):
end
=
time
.
time
()
time4
=
(
end
-
begin
)
# begin = time.time()
topic_useful_tag_id_list
=
instance
.
get_topic_useful_tag_id_list
()
res
[
"useful_tag_list"
]
=
topic_useful_tag_id_list
# end = time.time()
# time5 = (end - begin)
# # 片假名
# re_jp_pian_words = re.compile(u"[\u30a0-\u30ff]+")
# m_pian = re_jp_pian_words.search(instance.content, 0)
...
...
trans2es/utils/user_transfer.py
View file @
27b037ea
...
...
@@ -73,6 +73,7 @@ class UserTransfer(object):
try
:
res
[
"tag_list"
]
=
instance
.
get_user_tag_id_list
()
res
[
"useful_tag_list"
]
=
instance
.
get_user_useful_tag_id_list
()
res
[
"attention_user_id_list"
]
=
cls
.
get_follow_user_id_list
(
userInstance
=
instance
)
# res["attention_group_id_list"] = instance.get_attention_group_id_list()
...
...
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