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
f68bc9e3
Commit
f68bc9e3
authored
May 05, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify pictorial sort
parent
376b59c7
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
11 deletions
+48
-11
pictorial.json
trans2es/mapping/pictorial.json
+3
-1
pictorial.py
trans2es/models/pictorial.py
+4
-8
topic.py
trans2es/models/topic.py
+13
-0
pictorial_transfer.py
trans2es/utils/pictorial_transfer.py
+28
-2
No files found.
trans2es/mapping/pictorial.json
View file @
f68bc9e3
...
...
@@ -16,6 +16,7 @@
"tag_id"
:{
"type"
:
"long"
},
"tag_name"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_index"
},
"topic_id_list"
:{
"type"
:
"long"
},
"effective"
:{
"type"
:
"boolean"
}
"effective"
:{
"type"
:
"boolean"
},
"offline_score"
:{
"type"
:
"long"
}
}
}
\ No newline at end of file
trans2es/models/pictorial.py
View file @
f68bc9e3
...
...
@@ -36,7 +36,6 @@ class PictorialTopics(models.Model):
pictorial_id
=
models
.
BigIntegerField
(
verbose_name
=
u'画报ID'
)
topic_id
=
models
.
BigIntegerField
(
verbose_name
=
u'帖子ID'
)
is_online
=
models
.
BooleanField
(
verbose_name
=
u"是否有效"
,
default
=
True
)
is_online
=
models
.
BooleanField
(
verbose_name
=
u'是否上线'
)
is_deleted
=
models
.
BooleanField
(
verbose_name
=
u'是否删除'
)
...
...
@@ -59,18 +58,15 @@ class Pictorial(models.Model):
creator_id
=
models
.
BigIntegerField
(
verbose_name
=
u'画报用户ID'
)
icon
=
models
.
CharField
(
verbose_name
=
u'画报名称'
,
max_length
=
255
)
topic_num
=
models
.
IntegerField
(
verbose_name
=
u'次数'
)
add_score
=
models
.
IntegerField
(
verbose_name
=
u'人工权重'
)
def
get_topic_id
(
self
):
try
:
topic_id
=
[]
topic_id_list
=
PictorialTopics
.
objects
.
filter
(
pictorial_id
=
self
.
id
)
.
values_list
(
"topic_id"
,
flat
=
True
)
for
i
in
topic_id_list
:
topic_id
.
append
(
i
)
return
topic_id
topic_id_list
=
PictorialTopics
.
objects
.
filter
(
pictorial_id
=
self
.
id
,
is_online
=
True
,
is_deleted
=
False
)
.
values_list
(
"topic_id"
,
flat
=
True
)
return
topic_id_list
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
False
return
[]
def
get_effective
(
self
,
topic_id_list
):
...
...
trans2es/models/topic.py
View file @
f68bc9e3
...
...
@@ -130,6 +130,19 @@ class Topic(models.Model):
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
False
def
get_topic_image_num
(
self
,
topic_id
):
"""
:remark 获取指定帖子的图片数量
:param topic_id:
:return:
"""
try
:
query_list
=
TopicImage
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
topic_id
=
topic_id
,
is_deleted
=
False
,
is_online
=
True
)
.
values_list
(
"url"
,
flat
=
True
)
return
len
(
query_list
)
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
0
def
topic_has_image
(
self
):
try
:
has_image
=
False
...
...
trans2es/utils/pictorial_transfer.py
View file @
f68bc9e3
...
...
@@ -5,13 +5,39 @@ import sys
import
logging
import
traceback
from
libs.tools
import
tzlc
from
trans2es.models.topic
import
Topic
class
PictorialTransfer
(
object
):
def
__init__
(
self
):
pass
@classmethod
def
get_offline_score
(
cls
,
instance
,
topic_id_list
):
try
:
total_offline_score
=
0
topic_image_num
=
0
for
topic_id
in
topic_id_list
:
topic_image_num
+=
Topic
.
get_topic_image_num
(
topic_id
)
if
topic_image_num
>=
6
and
topic_image_num
<=
10
:
total_offline_score
+=
30
elif
topic_image_num
>
10
and
topic_image_num
<=
20
:
total_offline_score
+=
60
elif
topic_image_num
>
20
and
topic_image_num
<=
50
:
total_offline_score
+=
80
elif
topic_image_num
>
50
:
total_offline_score
+=
100
total_offline_score
+=
instance
.
add_score
if
instance
.
is_recommend
:
total_offline_score
+=
100
return
total_offline_score
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
0
@classmethod
def
get_poctorial_data
(
cls
,
instance
):
try
:
...
...
@@ -38,7 +64,7 @@ class PictorialTransfer(object):
res
[
"tag_name"
]
=
instance
.
get_tag_by_name
(
tag_id
)
res
[
"topic_id_list"
]
=
instance
.
get_topic_id
()
res
[
"effective"
]
=
instance
.
get_effective
(
res
[
"topic_id_list"
])
res
[
"offline_score"
]
=
cls
.
get_offline_score
(
instance
,
res
[
"topic_id_list"
])
return
res
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