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
6e9ee2c5
Commit
6e9ee2c5
authored
Sep 05, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'day_week_mouth' into 'master'
Day week mouth See merge request
!462
parents
4dab11a7
b6da0fd6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
81 additions
and
21 deletions
+81
-21
group.py
search/views/group.py
+81
-21
No files found.
search/views/group.py
View file @
6e9ee2c5
...
...
@@ -16,7 +16,7 @@ from libs.es import ESPerform
from
trans2es.models.topic
import
CommunityCategoryTagRelation
from
trans2es.models.pictorial
import
PictorialTopics
from
trans2es.models.pictorial
import
CommunityPictorialActivity
from
alpha_types.venus
import
PICTORIAL_ACTIVITY_SORT
from
alpha_types.venus
import
PICTORIAL_ACTIVITY_SORT
,
PICTORIAL_TOPIC_SORT
from
search.views.tag
import
get_same_tagset_ids
...
...
@@ -303,10 +303,11 @@ 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
):
def
pictorial_topic_sort
(
pictorial_id
=-
1
,
offset
=
0
,
size
=
10
,
sort_type
=
PICTORIAL_TOPIC_SORT
.
HOT
):
"""
:remark 画报排序 人气 部分
人气按照票数从大到小排序,相同票数按照图片票数更新时间由旧到新排序
2019-8-19新增日榜,周榜,月榜
:param user_id:
:param sort_type:
:param offset:
...
...
@@ -314,6 +315,35 @@ def pictorial_topic_sort(pictorial_id=-1, offset=0, size=10):
:return:
"""
try
:
days2
=
0
if
sort_type
==
PICTORIAL_TOPIC_SORT
.
DAY_HOT
:
days2
=
1
if
sort_type
==
PICTORIAL_TOPIC_SORT
.
WEEK_HOT
:
days2
=
7
if
sort_type
==
PICTORIAL_TOPIC_SORT
.
MOUTH_HOT
:
days2
=
30
now
=
datetime
.
datetime
.
now
()
yesterday2
=
now
-
datetime
.
timedelta
(
days
=
days2
)
yesterday_begin_time
=
"
%
s-
%
s-
%
s
%
s:
%
s:
%
s"
%
(
yesterday2
.
year
,
yesterday2
.
month
,
yesterday2
.
day
,
yesterday2
.
hour
,
yesterday2
.
minute
,
yesterday2
.
second
)
yesterday_end_time
=
"
%
s-
%
s-
%
s
%
s:
%
s:
%
s"
%
(
now
.
year
,
now
.
month
,
now
.
day
,
now
.
hour
,
now
.
minute
,
now
.
second
)
logging
.
info
(
"get yesterday_begin_time:
%
s"
%
yesterday_begin_time
)
logging
.
info
(
"get yesterday_end_time:
%
s"
%
yesterday_end_time
)
formatStr
=
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
tm_begin
=
time
.
strptime
(
yesterday_begin_time
,
formatStr
)
tm_end
=
time
.
strptime
(
yesterday_end_time
,
formatStr
)
yesterday_begintime
=
time
.
mktime
(
tm_begin
)
yesterday_endtime
=
time
.
mktime
(
tm_end
)
logging
.
info
(
"get yesterday_begin_time:
%
s"
%
yesterday_begintime
)
logging
.
info
(
"get yesterday_end_time:
%
s"
%
yesterday_endtime
)
if
not
isinstance
(
pictorial_id
,
int
):
pictorial_id
=
-
1
q
=
{
"query"
:
{
"bool"
:
{
...
...
@@ -321,26 +351,14 @@ def pictorial_topic_sort(pictorial_id=-1, offset=0, size=10):
{
"term"
:
{
"is_online"
:
True
}},
{
"term"
:
{
"is_deleted"
:
False
}},
{
"term"
:
{
"pictorial_id"
:
pictorial_id
}}
# {
# "nested": {
# "path": "related_billboard",
# "query": {
# "bool": {
# "must": [
# {
# "term": {
# "related_billboard.pictorial_id": pictorial_id
# }
# }
# ]
# }
# }
# }
# }
]
}
},
"sort"
:
[
}
}
if
sort_type
==
PICTORIAL_TOPIC_SORT
.
HOT
:
q
[
"sort"
]
=
[
{
"related_billboard.total_vote_cnt"
:
{
"order"
:
"desc"
,
"nested_path"
:
"related_billboard"
,
...
...
@@ -354,7 +372,49 @@ def pictorial_topic_sort(pictorial_id=-1, offset=0, size=10):
{
"create_time"
:
{
"order"
:
"desc"
}}
]
}
else
:
q
[
"query"
][
"bool"
][
"must"
]
.
append
(
{
"nested"
:
{
"path"
:
"related_billboard"
,
"query"
:
{
"bool"
:
{
"must"
:
[
{
"range"
:
{
"related_billboard.topic_add_createtime"
:
{
"gte"
:
yesterday_begintime
,
"lte"
:
yesterday_endtime
}
}
}
]
}
}
}
})
# q["sort"] = [
# {"related_billboard.topic_add_createtime": {
# "order": "desc",
# "nested_path": "related_billboard",
# "missing": "_last"
# }}
# ]
q
[
"sort"
]
=
[
{
"related_billboard.total_vote_cnt"
:
{
"order"
:
"desc"
,
"nested_path"
:
"related_billboard"
,
"missing"
:
"_last"
,
"nested_filter"
:
{
"term"
:
{
"related_billboard.pictorial_id"
:
pictorial_id
}
}
}},
{
"create_time"
:
{
"order"
:
"desc"
}}
]
logging
.
info
(
"get qqqqqq:
%
s"
%
q
)
pict_pictorial_ids_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