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
d627a6e9
Commit
d627a6e9
authored
Apr 04, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'test' of git.wanmeizhensuo.com:alpha/physical into test
parents
ba594583
77250083
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
80 additions
and
3 deletions
+80
-3
workspace.xml
.idea/workspace.xml
+0
-0
topic.py
search/utils/topic.py
+12
-0
group.py
search/views/group.py
+42
-3
topic-v1.json
trans2es/mapping/topic-v1.json
+2
-0
topic.json
trans2es/mapping/topic.json
+1
-0
topic.py
trans2es/models/topic.py
+21
-0
topic_transfer.py
trans2es/utils/topic_transfer.py
+2
-0
No files found.
.idea/workspace.xml
View file @
d627a6e9
This diff is collapsed.
Click to expand it.
search/utils/topic.py
View file @
d627a6e9
...
...
@@ -747,6 +747,18 @@ class TopicUtils(object):
"order"
:
"desc"
},
})
elif
sort_by
==
TOPIC_SEARCH_SORT
.
VOTE_NUM_AEC
:
sort_rule
.
append
({
"total_vote_num"
:
{
"order"
:
"asc"
},
})
elif
sort_by
==
TOPIC_SEARCH_SORT
.
VOTE_NUM_DESC
:
sort_rule
.
append
({
"total_vote_num"
:
{
"order"
:
"desc"
},
})
return
sort_rule
...
...
search/views/group.py
View file @
d627a6e9
...
...
@@ -92,8 +92,6 @@ def pictorial_topic(topic_id=-1, offset=0, size=10):
:return:
"""
try
:
if
not
isinstance
(
topic_id
,
int
):
user_id
=
-
1
# 获取es链接对象
es_cli_obj
=
ESPerform
.
get_cli
()
...
...
@@ -167,7 +165,7 @@ def pictorial_topic(topic_id=-1, offset=0, size=10):
"term"
:
{
"is_online"
:
True
}
},{
},
{
"term"
:
{
"is_deleted"
:
False
}
...
...
@@ -202,3 +200,44 @@ def pictorial_topic(topic_id=-1, offset=0, size=10):
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
{
"pictorial_ids_list"
:
[]}
@bind
(
"physical/search/pictorial_topic_sort"
)
def
pictorial_topic_sort
(
pictorial_id
=-
1
,
offset
=
0
,
size
=
10
):
"""
:remark 小组排序,缺少:前1天发评论人数*x
:param user_id:
:param sort_type:
:param offset:
:param size:
:return:
"""
try
:
if
not
isinstance
(
pictorial_id
,
int
):
user_id
=
-
1
q
=
{
"query"
:{
"term"
:{
"pictorial_id"
:
pictorial_id
}
},
"sort"
:{
"vote_num"
:{
"order"
:
"desc"
}
}
}
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
)
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
}
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
{
"pict_pictorial_ids_list"
:
[]}
trans2es/mapping/topic-v1.json
View file @
d627a6e9
...
...
@@ -5,12 +5,14 @@
"is_online"
:{
"type"
:
"boolean"
},
//上线
"is_deleted"
:{
"type"
:
"boolean"
},
"vote_num"
:{
"type"
:
"long"
},
"total_vote_num"
:{
"type"
:
"long"
},
"reply_num"
:{
"type"
:
"long"
},
"name"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_index"
},
"description"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_index"
},
"content"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_index"
},
"content_level"
:{
"type"
:
"text"
},
"user_id"
:{
"type"
:
"long"
},
"user_nick_name"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_index"
},
//帖子用户名
"group_id"
:{
"type"
:
"long"
},
//所在组ID
"tag_list"
:{
"type"
:
"long"
},
//标签属性
"edit_tag_list"
:{
"type"
:
"long"
},
//编辑标签
...
...
trans2es/mapping/topic.json
View file @
d627a6e9
...
...
@@ -5,6 +5,7 @@
"is_online"
:{
"type"
:
"boolean"
},
//上线
"is_deleted"
:{
"type"
:
"boolean"
},
"vote_num"
:{
"type"
:
"long"
},
"total_vote_num"
:{
"type"
:
"long"
},
"reply_num"
:{
"type"
:
"long"
},
"name"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_index"
},
"description"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_index"
},
...
...
trans2es/models/topic.py
View file @
d627a6e9
...
...
@@ -82,6 +82,14 @@ class Topic(models.Model):
platform
=
models
.
IntegerField
(
verbose_name
=
u'平台来源'
,
choices
=
GRAP_PLATFORM
,
default
=
GRAP_PLATFORM
.
ALPHA
)
platform_id
=
models
.
BigIntegerField
(
verbose_name
=
'用平台ID'
,
null
=
True
)
def
get_virtual_vote_num
(
self
):
try
:
topic_extra
=
TopicExtra
.
object
.
get
(
topic_id
=
self
.
id
)
return
topic_extra
.
virtual_vote_num
except
:
return
0
def
get_pictorial_id
(
self
):
try
:
pictorial_id_list
=
[]
...
...
@@ -238,3 +246,16 @@ class PictorialTopic(models.Model):
is_online
=
models
.
BooleanField
(
verbose_name
=
u"是否有效"
,
default
=
True
)
is_online
=
models
.
BooleanField
(
verbose_name
=
u'是否上线'
)
is_deleted
=
models
.
BooleanField
(
verbose_name
=
u'是否删除'
)
class
TopicExtra
(
models
.
Model
):
"""帖子相关额外信息"""
class
Meta
:
verbose_name
=
'帖子额外信息'
app_label
=
'community'
db_table
=
'topic_extra'
id
=
models
.
IntegerField
(
verbose_name
=
u'ID'
,
primary_key
=
True
)
topic_id
=
models
.
IntegerField
(
verbose_name
=
u"帖子ID"
,
db_index
=
True
)
virtual_vote_num
=
models
.
IntegerField
(
verbose_name
=
"帖子虚拟点赞"
)
trans2es/utils/topic_transfer.py
View file @
d627a6e9
...
...
@@ -109,6 +109,8 @@ class TopicTransfer(object):
res
[
"update_time"
]
=
tzlc_update_time
res
[
"update_time_val"
]
=
int
(
time
.
mktime
(
tzlc_update_time
.
timetuple
()))
res
[
"total_vote_num"
]
=
instance
.
get_virtual_vote_num
()
+
instance
.
vote_num
logging
.
info
(
"test topic transfer time cost,time0:
%
d,time1:
%
d,time2:
%
d,time3:
%
d,time4:
%
d"
%
(
time0
,
time1
,
time2
,
time3
,
time4
))
return
res
except
:
...
...
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