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
96e96568
Commit
96e96568
authored
May 16, 2019
by
Kai
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'hk' into hk_now
parents
7cf6330b
b9d20bc7
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
61 additions
and
33 deletions
+61
-33
Project.xml
.idea/codeStyles/Project.xml
+0
-25
topic.py
search/utils/topic.py
+12
-5
group.py
search/views/group.py
+7
-3
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
+16
-0
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.
.idea/codeStyles/Project.xml
View file @
96e96568
...
...
@@ -24,29 +24,5 @@
<option
name=
"ITERATION_ELEMENTS_WRAPPING"
value=
"chop_down_if_not_single"
/>
</formatting-settings>
</DBN-SQL>
<DBN-PSQL>
<case-options
enabled=
"false"
>
<option
name=
"KEYWORD_CASE"
value=
"lower"
/>
<option
name=
"FUNCTION_CASE"
value=
"lower"
/>
<option
name=
"PARAMETER_CASE"
value=
"lower"
/>
<option
name=
"DATATYPE_CASE"
value=
"lower"
/>
<option
name=
"OBJECT_CASE"
value=
"preserve"
/>
</case-options>
<formatting-settings
enabled=
"false"
/>
</DBN-PSQL>
<DBN-SQL>
<case-options
enabled=
"false"
>
<option
name=
"KEYWORD_CASE"
value=
"lower"
/>
<option
name=
"FUNCTION_CASE"
value=
"lower"
/>
<option
name=
"PARAMETER_CASE"
value=
"lower"
/>
<option
name=
"DATATYPE_CASE"
value=
"lower"
/>
<option
name=
"OBJECT_CASE"
value=
"preserve"
/>
</case-options>
<formatting-settings
enabled=
"false"
>
<option
name=
"STATEMENT_SPACING"
value=
"one_line"
/>
<option
name=
"CLAUSE_CHOP_DOWN"
value=
"chop_down_if_statement_long"
/>
<option
name=
"ITERATION_ELEMENTS_WRAPPING"
value=
"chop_down_if_not_single"
/>
</formatting-settings>
</DBN-SQL>
</code_scheme>
</component>
\ No newline at end of file
search/utils/topic.py
View file @
96e96568
...
...
@@ -35,7 +35,7 @@ class TopicUtils(object):
}
q
[
"_source"
]
=
{
"include"
:
[
"tag_list"
,
"attention_user_id_list"
,
"pick_user_id_list"
,
"same_pictorial_user_id_list"
]
"include"
:
[
"tag_list"
,
"useful_tag_list"
,
"attention_user_id_list"
,
"pick_user_id_list"
,
"same_pictorial_user_id_list"
]
}
result_dict
=
ESPerform
.
get_search_results
(
ESPerform
.
get_cli
(),
"user"
,
q
,
offset
,
size
)
...
...
@@ -127,7 +127,7 @@ class TopicUtils(object):
query_type
=
TopicPageType
.
HOME_RECOMMEND
,
filter_topic_id_list
=
[],
test_score
=
False
,
must_topic_id_list
=
[],
recommend_tag_list
=
[],
user_similar_score_list
=
[],
index_type
=
"topic"
,
routing
=
None
,
attention_tag_list
=
[],
linucb_user_id_list
=
[],
disable_collpase
=
False
):
linucb_user_id_list
=
[],
disable_collpase
=
False
,
usefulrecall
=
-
1
):
"""
:remark:获取首页推荐帖子列表
:param user_id:
...
...
@@ -141,14 +141,14 @@ class TopicUtils(object):
# pick_user_id_list = list()
# same_group_id_list = list()
user_tag_list
=
list
()
useful_tag_id_list
=
list
()
result_dict
=
TopicUtils
.
get_related_user_info
(
user_id
,
0
,
1
)
if
len
(
result_dict
[
"hits"
])
==
0
:
logging
.
warning
(
"not find user_id:
%
d in es!"
%
int
(
user_id
))
else
:
attention_user_info_list
=
result_dict
[
"hits"
][
0
][
"_source"
][
"attention_user_id_list"
]
attention_user_id_list
=
[
item
[
"user_id"
]
for
item
in
attention_user_info_list
]
useful_tag_id_list
=
result_dict
[
"hits"
][
0
][
"_source"
][
"useful_tag_list"
]
# pick_user_info_list = result_dict["hits"][0]["_source"]["pick_user_id_list"]
# pick_user_id_list = [item["user_id"] for item in pick_user_info_list]
...
...
@@ -197,7 +197,14 @@ class TopicUtils(object):
"weight"
:
100
}
)
if
len
(
useful_tag_id_list
)
>
0
and
usefulrecall
!=
-
1
:
functions_list
.
append
(
{
"filter"
:
{
"bool"
:
{
"must"
:
{
"terms"
:
{
"tag_list"
:
useful_tag_id_list
}}}},
"weight"
:
100
}
)
query_function_score
=
{
"query"
:
{
"bool"
:
{
...
...
search/views/group.py
View file @
96e96568
...
...
@@ -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"
)
...
...
@@ -209,7 +210,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:
...
...
@@ -241,12 +242,15 @@ def pictorial_topic_sort(pictorial_id=-1, offset=0, size=10):
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
)
for
item
in
result_dict
[
"hits"
]:
topic_id
=
item
[
"_source"
][
"id"
]
pict_pictorial_ids_list
.
append
(
topic_id
)
if
len
(
pict_pictorial_ids_list
)
>
0
and
offset
==
0
:
pict_pictorial_ids_list
=
list
(
PictorialTopics
.
objects
.
filter
(
pictorial_id
=
pictorial_id
,
is_online
=
True
,
is_deleted
=
False
)
.
values_list
(
"topic_id"
,
flat
=
True
)[
offset
:
size
])
return
{
"pict_pictorial_ids_list"
:
pict_pictorial_ids_list
}
except
:
...
...
trans2es/mapping/topic-high-star.json
View file @
96e96568
...
...
@@ -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 @
96e96568
...
...
@@ -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 @
96e96568
...
...
@@ -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 @
96e96568
...
...
@@ -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 @
96e96568
...
...
@@ -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 @
96e96568
...
...
@@ -191,6 +191,22 @@ 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
)
.
values_list
(
"tag_id"
,
"is_online"
,
"is_body_esthetics"
,
flat
=
True
)
for
tag_item
in
tag_id_list
:
is_online
=
tag_item
.
is_online
is_body_esthetics
=
tag_item
.
is_body_esthetics
if
is_online
and
is_body_esthetics
!=
0
:
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
()
...
...
trans2es/models/user.py
View file @
96e96568
...
...
@@ -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 @
96e96568
...
...
@@ -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 @
96e96568
...
...
@@ -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