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
钟尚武
physical
Commits
8fc00b85
Commit
8fc00b85
authored
Apr 26, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into 'test'
Master See merge request
alpha/physical!305
parents
d90373b8
c6686a11
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
22 deletions
+49
-22
topic.py
search/utils/topic.py
+12
-3
tag.py
search/views/tag.py
+1
-1
topic.py
trans2es/models/topic.py
+32
-16
topic_transfer.py
trans2es/utils/topic_transfer.py
+4
-2
No files found.
search/utils/topic.py
View file @
8fc00b85
...
...
@@ -182,6 +182,14 @@ class TopicUtils(object):
}
},
"weight"
:
1000
},
{
"filter"
:
{
"term"
:
{
"is_excellent"
:
1
}
},
"weight"
:
500
}
]
...
...
@@ -219,7 +227,7 @@ class TopicUtils(object):
{
"filter"
:
{
"bool"
:
{
"should"
:
{
"terms"
:
{
"tag_list"
:
topic_tag_list
}}}},
"weight"
:
10
000
"weight"
:
2
000
}
)
...
...
@@ -228,7 +236,7 @@ class TopicUtils(object):
{
"filter"
:
{
"bool"
:
{
"should"
:
{
"term"
:
{
"user_id"
:
topic_user_id
}}}},
"weight"
:
50
00
"weight"
:
15
00
}
)
query_function_score
=
{
...
...
@@ -312,8 +320,9 @@ class TopicUtils(object):
q
[
"collapse"
]
=
{
"field"
:
"user_id"
}
# "includes": ["id", "pictorial_id", "offline_score", "user_id", "edit_tag_list"]
q
[
"_source"
]
=
{
"includes"
:
[
"id"
,
"pictorial_id"
,
"offline_score"
,
"user_id"
,
"edit_tag_list"
]
"includes"
:
[
"id"
]
}
q
[
"sort"
]
=
[
# {
...
...
search/views/tag.py
View file @
8fc00b85
...
...
@@ -160,7 +160,7 @@ def identity_tag_name(topic_content):
body
=
{
'text'
:
topic_content
,
'analyzer'
:
"gm_default_
search
"
'analyzer'
:
"gm_default_
index
"
}
cli_info
=
settings
.
TAG_ES_INFO_LIST
...
...
trans2es/models/topic.py
View file @
8fc00b85
...
...
@@ -43,6 +43,20 @@ class TopicImage(models.Model):
create_time
=
models
.
DateTimeField
(
verbose_name
=
u'创建时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
update_time
=
models
.
DateTimeField
(
verbose_name
=
u'更新时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
class
ExcellentTopic
(
models
.
Model
):
"""优质帖子"""
class
Meta
:
verbose_name
=
"优质帖子"
db_table
=
"excellent_topic"
id
=
models
.
IntegerField
(
verbose_name
=
u'ID'
,
primary_key
=
True
)
topic_id
=
models
.
IntegerField
(
verbose_name
=
u"帖子ID"
,
db_index
=
True
)
is_online
=
models
.
BooleanField
(
verbose_name
=
u'是否上线'
)
is_deleted
=
models
.
BooleanField
(
verbose_name
=
u'是否删除'
)
excellent_type
=
models
.
IntegerField
(
verbose_name
=
u"优质类型"
,
db_index
=
True
)
create_time
=
models
.
DateTimeField
(
verbose_name
=
u'创建时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
update_time
=
models
.
DateTimeField
(
verbose_name
=
u'更新时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
class
Topic
(
models
.
Model
):
class
Meta
:
...
...
@@ -175,6 +189,17 @@ class Topic(models.Model):
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
[]
def
judge_if_excellent_topic
(
self
,
topic_id
):
try
:
excelllect_object
=
ExcellentTopic
.
objects
.
filter
(
topic_id
=
topic_id
)
.
first
()
if
excelllect_object
and
excelllect_object
.
is_online
and
not
excelllect_object
.
is_deleted
:
return
True
else
:
return
False
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
False
def
get_topic_offline_score
(
self
):
try
:
offline_score
=
0.0
...
...
@@ -198,8 +223,14 @@ class Topic(models.Model):
elif
self
.
content_level
==
'4'
:
offline_score
+=
5.0
elif
self
.
content_level
==
'6'
:
offline_score
+=
100.0
offline_score
+=
400.0
is_excellent
=
self
.
judge_if_excellent_topic
(
self
.
id
)
if
is_excellent
:
offline_score
+=
200.0
if
self
.
language_type
==
1
:
offline_score
+=
100.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()
...
...
@@ -266,21 +297,6 @@ class TopicExtra(models.Model):
virtual_vote_num
=
models
.
IntegerField
(
verbose_name
=
"帖子虚拟点赞"
)
class
ExcellentTopic
(
models
.
Model
):
"""优质帖子"""
class
Meta
:
verbose_name
=
"优质帖子"
db_table
=
"excellent_topic"
id
=
models
.
IntegerField
(
verbose_name
=
u'ID'
,
primary_key
=
True
)
topic_id
=
models
.
IntegerField
(
verbose_name
=
u"帖子ID"
,
db_index
=
True
)
is_online
=
models
.
BooleanField
(
verbose_name
=
u'是否上线'
)
is_deleted
=
models
.
BooleanField
(
verbose_name
=
u'是否删除'
)
excellent_type
=
models
.
IntegerField
(
verbose_name
=
u"优质类型"
,
db_index
=
True
)
create_time
=
models
.
DateTimeField
(
verbose_name
=
u'创建时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
update_time
=
models
.
DateTimeField
(
verbose_name
=
u'更新时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
class
TopicHomeRecommend
(
models
.
Model
):
"""运营位帖子"""
...
...
trans2es/utils/topic_transfer.py
View file @
8fc00b85
...
...
@@ -115,8 +115,10 @@ class TopicTransfer(object):
if
is_excellect
:
res
[
"is_excellent"
]
=
1
else
:
excelllect_object
=
ExcellentTopic
.
objects
.
filter
(
topic_id
=
instance
.
id
)
.
first
()
if
excelllect_object
and
excelllect_object
.
is_online
and
not
excelllect_object
.
is_deleted
:
# excelllect_object = ExcellentTopic.objects.filter(topic_id=instance.id).first()
# if excelllect_object and excelllect_object.is_online and not excelllect_object.is_deleted:
is_excellent
=
instance
.
judge_if_excellent_topic
(
instance
.
id
)
if
is_excellent
:
res
[
"is_excellent"
]
=
1
else
:
res
[
"is_excellent"
]
=
0
...
...
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