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
ba127bee
Commit
ba127bee
authored
Aug 19, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pictorial_day_week_mouth
parent
297c9dd6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
22 deletions
+70
-22
group.py
search/views/group.py
+70
-22
No files found.
search/views/group.py
View file @
ba127bee
...
@@ -15,7 +15,7 @@ from search.utils.common import GroupSortTypes
...
@@ -15,7 +15,7 @@ from search.utils.common import GroupSortTypes
from
libs.es
import
ESPerform
from
libs.es
import
ESPerform
from
trans2es.models.pictorial
import
PictorialTopics
from
trans2es.models.pictorial
import
PictorialTopics
from
trans2es.models.pictorial
import
CommunityPictorialActivity
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
@bind
(
"physical/search/query_pictorial"
)
@bind
(
"physical/search/query_pictorial"
)
...
@@ -239,10 +239,11 @@ def pictorial_topic(topic_id=-1, offset=0, size=10):
...
@@ -239,10 +239,11 @@ def pictorial_topic(topic_id=-1, offset=0, size=10):
@bind
(
"physical/search/pictorial_topic_sort"
)
@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 画报排序 人气 部分
:remark 画报排序 人气 部分
人气按照票数从大到小排序,相同票数按照图片票数更新时间由旧到新排序
人气按照票数从大到小排序,相同票数按照图片票数更新时间由旧到新排序
2019-8-19新增日榜,周榜,月榜
:param user_id:
:param user_id:
:param sort_type:
:param sort_type:
:param offset:
:param offset:
...
@@ -250,8 +251,38 @@ def pictorial_topic_sort(pictorial_id=-1, offset=0, size=10):
...
@@ -250,8 +251,38 @@ def pictorial_topic_sort(pictorial_id=-1, offset=0, size=10):
:return:
:return:
"""
"""
try
:
try
:
days1
=
0
days2
=
0
if
sort_type
==
PICTORIAL_TOPIC_SORT
.
DAY_HOT
:
days1
=
1
days2
=
1
if
sort_type
==
PICTORIAL_TOPIC_SORT
.
WEEK_HOT
:
days1
=
1
days2
=
7
if
sort_type
==
PICTORIAL_TOPIC_SORT
.
MOUTH_HOT
:
days1
=
1
days2
=
30
now
=
datetime
.
datetime
.
now
()
yesterday1
=
now
-
datetime
.
timedelta
(
days
=
days1
)
yesterday2
=
now
-
datetime
.
timedelta
(
days
=
days2
)
yesterday_begin_time
=
"
%
s-
%
s-
%
s 00:00:00"
%
(
yesterday2
.
year
,
yesterday2
.
month
,
yesterday2
.
day
)
yesterday_end_time
=
"
%
s-
%
s-
%
s 23:59:59"
%
(
yesterday1
.
year
,
yesterday1
.
month
,
yesterday1
.
day
)
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
):
if
not
isinstance
(
pictorial_id
,
int
):
user
_id
=
-
1
pictorial
_id
=
-
1
q
=
{
q
=
{
"query"
:
{
"query"
:
{
...
@@ -260,26 +291,14 @@ def pictorial_topic_sort(pictorial_id=-1, offset=0, size=10):
...
@@ -260,26 +291,14 @@ def pictorial_topic_sort(pictorial_id=-1, offset=0, size=10):
{
"term"
:
{
"is_online"
:
True
}},
{
"term"
:
{
"is_online"
:
True
}},
{
"term"
:
{
"is_deleted"
:
False
}},
{
"term"
:
{
"is_deleted"
:
False
}},
{
"term"
:
{
"pictorial_id"
:
pictorial_id
}}
{
"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"
:
{
{
"related_billboard.total_vote_cnt"
:
{
"order"
:
"desc"
,
"order"
:
"desc"
,
"nested_path"
:
"related_billboard"
,
"nested_path"
:
"related_billboard"
,
...
@@ -293,7 +312,36 @@ def pictorial_topic_sort(pictorial_id=-1, offset=0, size=10):
...
@@ -293,7 +312,36 @@ def pictorial_topic_sort(pictorial_id=-1, offset=0, size=10):
{
"create_time"
:
{
"order"
:
"desc"
}}
{
"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"
}}
]
logging
.
info
(
"get qqqqqq:
%
s"
%
q
)
logging
.
info
(
"get qqqqqq:
%
s"
%
q
)
pict_pictorial_ids_list
=
[]
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