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
adebab92
Commit
adebab92
authored
Aug 21, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into recomment_pictorial
parents
5a1d3b27
24598e75
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
142 additions
and
13 deletions
+142
-13
group.py
search/utils/group.py
+2
-7
group.py
search/views/group.py
+0
-3
pictorial.json
trans2es/mapping/pictorial.json
+6
-1
pictorial.py
trans2es/models/pictorial.py
+127
-1
topic.py
trans2es/models/topic.py
+1
-0
pictorial_transfer.py
trans2es/utils/pictorial_transfer.py
+6
-0
principal_online_comment1.py
vest/pictorial/principal_online_comment1.py
+0
-1
No files found.
search/utils/group.py
View file @
adebab92
...
...
@@ -221,7 +221,7 @@ class GroupUtils(object):
multi_fields
=
{
'name'
:
4
,
'description'
:
4
,
'tag_name'
:
4
'
edit_
tag_name'
:
4
}
query_fields
=
[
'^'
.
join
((
k
,
str
(
v
)))
for
(
k
,
v
)
in
multi_fields
.
items
()]
multi_match
=
{
...
...
@@ -255,12 +255,7 @@ class GroupUtils(object):
}
q
[
"sort"
]
=
[
{
"_script"
:
{
"type"
:
"number"
,
"script"
:
{
"lang"
:
"expression"
,
"source"
:
"_score+doc['offline_score']"
},
"real_user_activate_time"
:
{
"order"
:
"desc"
}
},
...
...
search/views/group.py
View file @
adebab92
...
...
@@ -283,9 +283,6 @@ def pictorial_topic_sort(pictorial_id=-1, offset=0, size=10):
:return:
"""
try
:
if
not
isinstance
(
pictorial_id
,
int
):
user_id
=
-
1
q
=
{
"query"
:
{
"bool"
:
{
...
...
trans2es/mapping/pictorial.json
View file @
adebab92
...
...
@@ -21,7 +21,12 @@
"is_default"
:{
"type"
:
"long"
},
"is_cover"
:{
"type"
:
"boolean"
},
"topic_vote_number"
:{
"type"
:
"long"
},
"activity_join"
:{
"type"
:
"long"
}
"activity_join"
:{
"type"
:
"long"
},
"latest_real_reply_time"
:{
"type"
:
"date"
,
"format"
:
"date_time_no_millis"
},
"latest_real_topic_time"
:{
"type"
:
"date"
,
"format"
:
"date_time_no_millis"
},
"real_user_activate_time"
:{
"type"
:
"date"
,
"format"
:
"date_time_no_millis"
},
"edit_tag_id"
:{
"type"
:
"long"
},
"edit_tag_name"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_search"
}
}
}
trans2es/models/pictorial.py
View file @
adebab92
...
...
@@ -2,9 +2,11 @@ import datetime
from
django.db
import
models
import
logging
import
traceback
from
django.conf
import
settings
from
trans2es.models.topic
import
Reply
from
.tag
import
Tag
from
.topic
import
Topic
,
TopicBillBoard
from
.user_extra
import
UserExtra
class
PictorialFollow
(
models
.
Model
):
...
...
@@ -127,6 +129,27 @@ class Pictorial(models.Model):
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
[]
def
get_edit_tag_id
(
self
):
try
:
tag_id_list
=
list
(
PictorialTag
.
objects
.
filter
(
pictorial_id
=
self
.
id
,
is_online
=
True
,
is_collection
=
1
)
.
values_list
(
"tag_id"
,
flat
=
True
))
return
tag_id_list
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
[]
def
get_edit_tag_name
(
self
,
tag_id
):
try
:
tag_name_list
=
list
(
Tag
.
objects
.
filter
(
id__in
=
tag_id
,
is_online
=
True
)
.
values_list
(
"name"
,
flat
=
True
))
return
tag_name_list
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
[]
def
get_is_cover
(
self
,
topic_id_list
):
try
:
effective_num
=
0
...
...
@@ -171,6 +194,108 @@ class Pictorial(models.Model):
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
[]
def
get_latest_real_reply_time
(
self
):
try
:
reply_query_results
=
Reply
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
pictorial_id
=
self
.
id
,
is_deleted
=
0
,
is_online
=
1
)
.
values
(
"user_id"
,
"create_time"
)
datetime_list
=
list
()
if
reply_query_results
.
count
()
>
0
:
for
reply
in
reply_query_results
:
UserExtra_results
=
UserExtra
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
user_id
=
reply
[
'user_id'
])
.
values
(
'is_shadow'
)
if
UserExtra_results
.
count
()
>
0
:
if
not
UserExtra_results
[
0
][
'is_shadow'
]:
datetime_list
.
append
(
reply
[
'create_time'
])
else
:
datetime_list
.
append
(
reply
[
'create_time'
])
if
len
(
datetime_list
)
>
0
:
dt
=
max
(
datetime_list
)
return
datetime
.
datetime
(
dt
.
year
,
dt
.
month
,
dt
.
day
,
dt
.
hour
,
dt
.
minute
,
dt
.
second
,
tzinfo
=
datetime
.
timezone
(
datetime
.
timedelta
(
hours
=
8
)))
else
:
return
datetime
.
datetime
(
1980
,
1
,
1
,
0
,
0
,
0
,
tzinfo
=
datetime
.
timezone
(
datetime
.
timedelta
(
hours
=
8
)))
except
:
return
datetime
.
datetime
(
1980
,
1
,
1
,
0
,
0
,
0
,
tzinfo
=
datetime
.
timezone
(
datetime
.
timedelta
(
hours
=
8
)))
def
get_latest_real_topic_time
(
self
):
try
:
topic_id_list
=
list
(
PictorialTopics
.
objects
.
filter
(
pictorial_id
=
self
.
id
,
is_online
=
True
,
is_deleted
=
False
)
.
values_list
(
"topic_id"
,
flat
=
True
))
logging
.
info
(
"get topic_id_list:
%
s"
%
topic_id_list
)
topic_info
=
Topic
.
objects
.
filter
(
id__in
=
topic_id_list
)
.
values
(
"user_id"
,
"create_time"
)
logging
.
info
(
"get topic_info:
%
s"
%
topic_info
)
datetime_list
=
list
()
if
topic_info
.
count
()
>
0
:
for
topic
in
topic_info
:
UserExtra_results
=
UserExtra
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
user_id
=
topic
[
'user_id'
])
.
values
(
'is_shadow'
)
if
UserExtra_results
.
count
()
>
0
:
if
not
UserExtra_results
[
0
][
'is_shadow'
]:
datetime_list
.
append
(
topic
[
'create_time'
])
else
:
datetime_list
.
append
(
topic
[
'create_time'
])
logging
.
info
(
"get datetime_list:
%
s"
%
datetime_list
)
if
len
(
datetime_list
)
>
0
:
dt
=
max
(
datetime_list
)
logging
.
info
(
"get max datetime_list:
%
s"
%
dt
)
return
datetime
.
datetime
(
dt
.
year
,
dt
.
month
,
dt
.
day
,
dt
.
hour
,
dt
.
minute
,
dt
.
second
,
tzinfo
=
datetime
.
timezone
(
datetime
.
timedelta
(
hours
=
8
)))
else
:
return
datetime
.
datetime
(
1980
,
1
,
1
,
0
,
0
,
0
,
tzinfo
=
datetime
.
timezone
(
datetime
.
timedelta
(
hours
=
8
)))
except
:
return
datetime
.
datetime
(
1980
,
1
,
1
,
0
,
0
,
0
,
tzinfo
=
datetime
.
timezone
(
datetime
.
timedelta
(
hours
=
8
)))
def
get_real_user_activate_time
(
self
):
try
:
reply_query_results
=
Reply
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
pictorial_id
=
self
.
id
,
is_deleted
=
0
,
is_online
=
1
)
.
values
(
"user_id"
,
"create_time"
)
datetime_list
=
list
()
if
reply_query_results
.
count
()
>
0
:
for
reply
in
reply_query_results
:
UserExtra_results
=
UserExtra
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
user_id
=
reply
[
'user_id'
])
.
values
(
'is_shadow'
)
if
UserExtra_results
.
count
()
>
0
:
if
not
UserExtra_results
[
0
][
'is_shadow'
]:
datetime_list
.
append
(
reply
[
'create_time'
])
else
:
datetime_list
.
append
(
reply
[
'create_time'
])
topic_id_list
=
list
(
PictorialTopics
.
objects
.
filter
(
pictorial_id
=
self
.
id
,
is_online
=
True
,
is_deleted
=
False
)
.
values_list
(
"topic_id"
,
flat
=
True
))
topic_info
=
Topic
.
objects
.
filter
(
id__in
=
topic_id_list
,
is_online
=
1
)
.
values
(
"user_id"
,
"create_time"
)
if
topic_info
.
count
()
>
0
:
for
topic
in
topic_info
:
UserExtra_results
=
UserExtra
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
user_id
=
topic
[
'user_id'
])
.
values
(
'is_shadow'
)
if
UserExtra_results
.
count
()
>
0
:
if
not
UserExtra_results
[
0
][
'is_shadow'
]:
datetime_list
.
append
(
topic
[
'create_time'
])
else
:
datetime_list
.
append
(
topic
[
'create_time'
])
logging
.
info
(
"get datetime_list:
%
s"
%
datetime_list
)
if
len
(
datetime_list
)
>
0
:
dt
=
max
(
datetime_list
)
logging
.
info
(
"get max datetime_list:
%
s"
%
dt
)
return
datetime
.
datetime
(
dt
.
year
,
dt
.
month
,
dt
.
day
,
dt
.
hour
,
dt
.
minute
,
dt
.
second
,
tzinfo
=
datetime
.
timezone
(
datetime
.
timedelta
(
hours
=
8
)))
else
:
return
datetime
.
datetime
(
1980
,
1
,
1
,
0
,
0
,
0
,
tzinfo
=
datetime
.
timezone
(
datetime
.
timedelta
(
hours
=
8
)))
except
:
return
datetime
.
datetime
(
1980
,
1
,
1
,
0
,
0
,
0
,
tzinfo
=
datetime
.
timezone
(
datetime
.
timedelta
(
hours
=
8
)))
class
PictorialTag
(
models
.
Model
):
"""画报关注标签"""
...
...
@@ -186,6 +311,7 @@ class PictorialTag(models.Model):
pictorial_id
=
models
.
BigIntegerField
(
verbose_name
=
u'画报ID'
,
max_length
=
20
)
tag_id
=
models
.
BigIntegerField
(
verbose_name
=
u'标签ID'
,
max_length
=
20
)
is_online
=
models
.
BooleanField
(
verbose_name
=
u'是否上线'
,
max_length
=
1
)
is_collection
=
models
.
IntegerField
(
verbose_name
=
u"是否编辑标签"
)
class
CommunityPictorialActivity
(
models
.
Model
):
...
...
trans2es/models/topic.py
View file @
adebab92
...
...
@@ -420,4 +420,5 @@ class Reply(models.Model):
create_time
=
models
.
DateTimeField
(
verbose_name
=
u'创建时间'
)
is_deleted
=
models
.
BooleanField
(
verbose_name
=
u'是否删除'
)
is_online
=
models
.
BooleanField
(
verbose_name
=
u'是否上线'
)
pictorial_id
=
models
.
IntegerField
(
verbose_name
=
u"榜单ID"
)
trans2es/utils/pictorial_transfer.py
View file @
adebab92
...
...
@@ -70,6 +70,12 @@ class PictorialTransfer(object):
res
[
"is_cover"
]
=
instance
.
get_is_cover
(
res
[
"topic_id_list"
])
res
[
"topic_vote_number"
]
=
instance
.
get_topic_vote_number
()
res
[
"activity_join"
]
=
instance
.
get_activity_join
()
res
[
"latest_real_reply_time"
]
=
instance
.
get_latest_real_reply_time
()
res
[
"latest_real_topic_time"
]
=
instance
.
get_latest_real_topic_time
()
res
[
"real_user_activate_time"
]
=
instance
.
get_real_user_activate_time
()
res
[
"edit_tag_id"
]
=
instance
.
get_edit_tag_id
()
res
[
"edit_tag_name"
]
=
instance
.
get_edit_tag_name
(
res
[
"edit_tag_id"
])
logging
.
info
(
"get data:
%
s"
%
res
)
return
res
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
...
...
vest/pictorial/principal_online_comment1.py
View file @
adebab92
...
...
@@ -60,7 +60,6 @@ def principal_online_comment1():
logging
.
info
(
"comment offline pictorial"
)
numtime1
,
numtime2
,
minute
=
time_conv_minute
(
30
,
0
)
user_id
,
data_vote
=
get_data
(
numtime1
,
numtime2
)
dicts
=
{}
random_num
=
0
if
user_id
:
for
i
in
user_id
:
...
...
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