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
294351f1
Commit
294351f1
authored
Aug 30, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'test' into 'day_week_mouth'
# Conflicts: # search/views/group.py
parents
42003a85
15d4baee
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
44 additions
and
23 deletions
+44
-23
collect_data.py
linucb/views/collect_data.py
+10
-5
topic.py
search/utils/topic.py
+3
-4
group.py
search/views/group.py
+5
-0
tag.py
search/views/tag.py
+0
-0
topic.py
search/views/topic.py
+0
-0
group.py
trans2es/models/group.py
+9
-8
pictorial.py
trans2es/models/pictorial.py
+2
-2
tag.py
trans2es/models/tag.py
+11
-0
pictorial_transfer.py
trans2es/utils/pictorial_transfer.py
+1
-1
auto_request.py
vest/request/auto_request.py
+1
-1
get_session.py
vest/request/get_session.py
+2
-2
No files found.
linucb/views/collect_data.py
View file @
294351f1
...
...
@@ -17,6 +17,8 @@ import libs.tools as Tools
from
trans2es.models.pictorial
import
CommunityPictorialHomeFeed
from
libs.error
import
logging_exception
import
os
from
search.views.tag
import
get_same_tagset_ids
class
KafkaManager
(
object
):
consumser_obj
=
None
...
...
@@ -91,7 +93,8 @@ class CollectData(object):
recommend_lin_pictorial_id_list
=
list
()
if
click_topic_tag_list
and
len
(
click_topic_tag_list
)
>
0
:
recommend_topic_id_list_click
,
recommend_topic_id_list_click_dict
=
ESPerform
.
get_tag_topic_list_dict
(
click_topic_tag_list
,
click_topic_tag_list_same_tagset_ids
=
get_same_tagset_ids
(
click_topic_tag_list
)
recommend_topic_id_list_click
,
recommend_topic_id_list_click_dict
=
ESPerform
.
get_tag_topic_list_dict
(
click_topic_tag_list_same_tagset_ids
,
have_read_topic_id_list
,
size
=
2
)
if
len
(
recommend_topic_id_list_click
)
>
0
:
recommend_topic_id_list
.
extend
(
recommend_topic_id_list_click
)
...
...
@@ -120,12 +123,14 @@ class CollectData(object):
# if len(recommend_topic_id_list)==0 and cursor==0 and len(redis_topic_list)>0:
# have_read_topic_id_list.extend(redis_topic_list[:2])
if
len
(
new_user_click_tag_list
)
>
0
:
tag_topic_id_list
,
tag_topic_dict
=
ESPerform
.
get_tag_topic_list_dict
(
new_user_click_tag_list
,
have_read_topic_id_list
)
recommend_lin_pictorial_id_list
=
ESPerform
.
get_tag_pictorial_id_list
(
new_user_click_tag_list
,
new_user_click_tag_list_same_tagset_ids
=
get_same_tagset_ids
(
new_user_click_tag_list
)
tag_topic_id_list
,
tag_topic_dict
=
ESPerform
.
get_tag_topic_list_dict
(
new_user_click_tag_list_same_tagset_ids
,
have_read_topic_id_list
)
recommend_lin_pictorial_id_list
=
ESPerform
.
get_tag_pictorial_id_list
(
new_user_click_tag_list_same_tagset_ids
,
have_read_lin_pictorial_id_list
)
else
:
tag_topic_id_list
,
tag_topic_dict
=
ESPerform
.
get_tag_topic_list_dict
(
tag_id_list
,
have_read_topic_id_list
)
recommend_lin_pictorial_id_list
=
ESPerform
.
get_tag_pictorial_id_list
(
tag_id_list
,
tag_id_list_same_tagset_ids
=
get_same_tagset_ids
(
tag_id_list
)
tag_topic_id_list
,
tag_topic_dict
=
ESPerform
.
get_tag_topic_list_dict
(
tag_id_list_same_tagset_ids
,
have_read_topic_id_list
)
recommend_lin_pictorial_id_list
=
ESPerform
.
get_tag_pictorial_id_list
(
tag_id_list_same_tagset_ids
,
have_read_lin_pictorial_id_list
)
if
len
(
recommend_topic_id_list
)
>
0
or
len
(
tag_topic_id_list
)
>
0
or
len
(
new_user_click_tag_list
)
>
0
:
...
...
search/utils/topic.py
View file @
294351f1
...
...
@@ -4,16 +4,14 @@
import
logging
import
traceback
import
json
from
alpha_types.venus
import
TOPIC_SEARCH_SORT
from
search.views.tag
import
get_same_tagset_ids
from
libs.es
import
ESPerform
from
.common
import
TopicDocumentField
from
search.utils.common
import
*
from
trans2es.models.pictorial
import
PictorialTopics
from
libs.cache
import
redis_client
class
TopicUtils
(
object
):
@classmethod
...
...
@@ -239,9 +237,10 @@ class TopicUtils(object):
}
query_function_score
[
"boost_mode"
]
=
"replace"
tag_ids
=
get_same_tagset_ids
(
tag_id
)
query_function_score
[
"query"
][
"bool"
][
"should"
]
=
[
{
'multi_match'
:
multi_match
},
{
"term
"
:
{
"tag_list"
:
tag_id
}},
{
"term
s"
:
{
"tag_list"
:
tag_ids
}},
{
"term"
:
{
"user_nick_name_pre"
:
query
.
lower
()}}
]
query_function_score
[
"query"
][
"bool"
][
"minimum_should_match"
]
=
1
...
...
search/views/group.py
View file @
294351f1
...
...
@@ -17,6 +17,7 @@ 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
,
PICTORIAL_TOPIC_SORT
from
search.views.tag
import
get_same_tagset_ids
@bind
(
"physical/search/query_pictorial"
)
...
...
@@ -148,6 +149,10 @@ def pictorial_topic(topic_id=-1, offset=0, size=10):
for
item
in
result_dict
[
"hits"
]:
pict_pictorial_ids_list
=
item
[
"_source"
][
"pictorial_id"
]
topic_tag_list
=
item
[
"_source"
][
"tag_list"
]
##拿到这些标签的同义词
topic_tag_list
=
get_same_tagset_ids
(
topic_tag_list
)
##先拿到当前帖子对应的标签的分类ID
tag_type_ids
=
CommunityCategoryTagRelation
.
objects
.
filter
(
tag_id__in
=
topic_tag_list
,
is_online
=
True
,
is_deleted
=
False
)
.
values_list
(
...
...
search/views/tag.py
View file @
294351f1
This diff is collapsed.
Click to expand it.
search/views/topic.py
View file @
294351f1
This diff is collapsed.
Click to expand it.
trans2es/models/group.py
View file @
294351f1
...
...
@@ -9,31 +9,33 @@ from libs.es import ESPerform
from
django.db
import
models
import
datetime
class
Group
(
models
.
Model
):
class
Meta
:
verbose_name
=
u'小组'
db_table
=
'group'
id
=
models
.
IntegerField
(
verbose_name
=
u"小组ID"
,
primary_key
=
True
)
id
=
models
.
IntegerField
(
verbose_name
=
u"小组ID"
,
primary_key
=
True
)
name
=
models
.
CharField
(
verbose_name
=
u'名称'
,
max_length
=
100
,
default
=
''
)
description
=
models
.
CharField
(
verbose_name
=
u'描述'
,
max_length
=
200
,
default
=
''
)
creator_id
=
models
.
IntegerField
(
verbose_name
=
u'创建者ID'
)
#icon = ImgUrlField('图标', max_length=255, img_type=IMG_TYPE.WATERMARK, default='')
#
icon = ImgUrlField('图标', max_length=255, img_type=IMG_TYPE.WATERMARK, default='')
icon
=
models
.
CharField
(
verbose_name
=
u'图标'
,
max_length
=
128
,
default
=
''
)
topic_num
=
models
.
IntegerField
(
verbose_name
=
u'帖子数'
,
default
=
0
)
is_online
=
models
.
BooleanField
(
verbose_name
=
u"是否有效"
,
default
=
True
)
is_deleted
=
models
.
BooleanField
(
verbose_name
=
"是否删除"
)
is_recommend
=
models
.
BooleanField
(
verbose_name
=
u"是否推荐"
,
default
=
False
)
create_time
=
models
.
DateTimeField
(
verbose_name
=
u'创建时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
create_time
=
models
.
DateTimeField
(
verbose_name
=
u'创建时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
update_time
=
models
.
DateTimeField
(
verbose_name
=
u'更新时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
#获取前一天4,5星发帖数
#
获取前一天4,5星发帖数
def
get_high_quality_topic_num
(
self
):
yesterday
=
datetime
.
datetime
.
now
()
-
datetime
.
timedelta
(
days
=
1
)
yesterday
=
datetime
.
datetime
.
now
()
-
datetime
.
timedelta
(
days
=
1
)
yesterday_begin_time
=
"
%
s-
%
s-
%
s 00:00:00"
%
(
yesterday
.
year
,
yesterday
.
month
,
yesterday
.
day
)
yesterday_end_time
=
"
%
s-
%
s-
%
s 23:59:59"
%
(
yesterday
.
year
,
yesterday
.
month
,
yesterday
.
day
)
topic_num
=
self
.
group_topics
.
filter
(
content_level__in
=
(
"4"
,
"5"
),
create_time__gte
=
yesterday_begin_time
,
create_time__lte
=
yesterday_end_time
)
.
count
()
topic_num
=
self
.
group_topics
.
filter
(
content_level__in
=
(
"4"
,
"5"
),
create_time__gte
=
yesterday_begin_time
,
create_time__lte
=
yesterday_end_time
)
.
count
()
return
topic_num
...
...
@@ -48,4 +50,4 @@ class Group(models.Model):
'create_time'
:
self
.
create_time
.
timestamp
(),
'update_time'
:
self
.
update_time
.
timestamp
(),
}
return
result
\ No newline at end of file
return
result
trans2es/models/pictorial.py
View file @
294351f1
...
...
@@ -93,7 +93,7 @@ class Pictorial(models.Model):
return
False
# 获取前一天4,5星发帖数
def
get_high_quality_topic_num
(
self
):
def
get_high_quality_topic_num
_pictorial
(
self
):
try
:
yesterday
=
datetime
.
datetime
.
now
()
-
datetime
.
timedelta
(
days
=
1
)
yesterday_begin_time
=
"
%
s-
%
s-
%
s 00:00:00"
%
(
yesterday
.
year
,
yesterday
.
month
,
yesterday
.
day
)
...
...
@@ -108,7 +108,7 @@ class Pictorial(models.Model):
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
False
return
0
def
get_tag_by_id
(
self
):
try
:
...
...
trans2es/models/tag.py
View file @
294351f1
...
...
@@ -107,4 +107,15 @@ class SettingsConfig(models.Model):
key
=
models
.
IntegerField
(
verbose_name
=
u"值"
)
val
=
models
.
IntegerField
(
verbose_name
=
"标签内容"
)
class
CommunityTagSetRelation
(
models
.
Model
):
class
Meta
:
verbose_name
=
"搜索热词"
db_table
=
"community_tag_set_relation"
id
=
models
.
IntegerField
(
primary_key
=
True
,
verbose_name
=
u"主键ID"
)
tag_id
=
models
.
IntegerField
(
verbose_name
=
u"标签ID"
)
tag_set_id
=
models
.
IntegerField
(
verbose_name
=
u"标签ID"
)
is_deleted
=
models
.
BooleanField
(
verbose_name
=
u"是否删除"
)
trans2es/utils/pictorial_transfer.py
View file @
294351f1
...
...
@@ -59,7 +59,7 @@ class PictorialTransfer(object):
update_time
=
instance
.
update_time
tzlc_udpate_time
=
tzlc
(
update_time
)
res
[
"update_time"
]
=
tzlc_udpate_time
res
[
"high_quality_topic_num"
]
=
instance
.
get_high_quality_topic_num
()
res
[
"high_quality_topic_num"
]
=
instance
.
get_high_quality_topic_num
_pictorial
()
tag_id_list
=
instance
.
get_tag_by_id
()
res
[
"tag_id"
]
=
tag_id_list
res
[
"tag_name"
]
=
instance
.
get_tag_by_name
(
tag_id_list
)
...
...
vest/request/auto_request.py
View file @
294351f1
...
...
@@ -315,7 +315,7 @@ def send_email(stat_data):
msg
=
MIMEText
(
stat_data
,
'plain'
,
'utf-8'
)
msg
[
'From'
]
=
formataddr
([
"李小芳"
,
my_sender
])
msg
[
"To"
]
=
formataddr
([
"李小芳"
,
my_user6
])
msg
[
'Subject'
]
=
str
(
datetime
.
date
.
today
())
+
"like的
测试
环境的自动点赞出问题了"
msg
[
'Subject'
]
=
str
(
datetime
.
date
.
today
())
+
"like的
线上
环境的自动点赞出问题了"
server
=
smtplib
.
SMTP_SSL
(
"smtp.exmail.qq.com"
,
465
)
server
.
login
(
my_sender
,
my_pass
)
server
.
sendmail
(
my_sender
,
[
my_user6
],
msg
.
as_string
())
...
...
vest/request/get_session.py
View file @
294351f1
...
...
@@ -5,8 +5,8 @@ import json
from
libs.cache
import
redis_client
from
libs.error
import
logging_exception
#
login_url = "http://earth.iyanzhi.com/api/account/login_pwd"
login_url
=
"http://earth.gmapp.env/api/account/login_pwd"
login_url
=
"http://earth.iyanzhi.com/api/account/login_pwd"
#
login_url = "http://earth.gmapp.env/api/account/login_pwd"
def
index_first
():
...
...
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