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
ff979cae
Commit
ff979cae
authored
Sep 27, 2019
by
高雅喆
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'gyz_es' into 'master'
问题索引增加画像field See merge request
alpha/physical!507
parents
cb772743
f938078e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
0 deletions
+88
-0
pictorial.json
trans2es/mapping/pictorial.json
+5
-0
portrait_stat.py
trans2es/models/portrait_stat.py
+77
-0
pictorial_transfer.py
trans2es/utils/pictorial_transfer.py
+6
-0
No files found.
trans2es/mapping/pictorial.json
View file @
ff979cae
...
...
@@ -4,6 +4,11 @@
"id"
:{
"type"
:
"long"
},
"is_online"
:{
"type"
:
"boolean"
},
//上线
"is_deleted"
:{
"type"
:
"boolean"
},
"is_new_pictorial"
:{
"type"
:
"boolean"
},
"pictorial_ctr_30"
:{
"type"
:
"double"
},
"like_rate_30"
:{
"type"
:
"double"
},
"pictorial_ctr_all"
:{
"type"
:
"double"
},
"like_rate_all"
:{
"type"
:
"double"
},
"is_recommend"
:{
"type"
:
"boolean"
},
"name"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_search"
},
"description"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_search"
},
...
...
trans2es/models/portrait_stat.py
View file @
ff979cae
import
logging
import
traceback
from
django.db
import
models
from
django.conf
import
settings
class
LikeDeviceTagStat
(
models
.
Model
):
...
...
@@ -29,3 +32,77 @@ class LikeTopicStat(models.Model):
is_new_topic
=
models
.
IntegerField
(
verbose_name
=
u"是否是新帖"
)
topic_ctr_30
=
models
.
FloatField
(
verbose_name
=
u"30天内回答的ctr"
)
like_rate_30
=
models
.
FloatField
(
verbose_name
=
u"30天内回答的点赞率"
)
class
LikePictorialStat
(
models
.
Model
):
class
Meta
:
verbose_name
=
u"30天内问题的stat"
db_table
=
"like_pictorial_stat"
id
=
models
.
IntegerField
(
primary_key
=
True
,
verbose_name
=
u"主键ID"
)
create_time
=
models
.
DateTimeField
(
verbose_name
=
u'统计创建时间'
)
update_time
=
models
.
DateTimeField
(
verbose_name
=
u'统计更新时间'
)
pictorial_id
=
models
.
IntegerField
(
verbose_name
=
u'问题id'
,
unique
=
True
)
is_new_pictorial
=
models
.
IntegerField
(
verbose_name
=
u"是否是新问题"
)
pictorial_ctr_30
=
models
.
FloatField
(
verbose_name
=
u"30天内问题的ctr"
)
like_rate_30
=
models
.
FloatField
(
verbose_name
=
u"30天内问题的点赞率"
)
pictorial_ctr_all
=
models
.
FloatField
(
verbose_name
=
u"历史该问题的ctr"
)
like_rate_all
=
models
.
FloatField
(
verbose_name
=
u"历史该问题的点赞率"
)
@classmethod
def
get_pictorial_is_new
(
cls
,
pictorial_id
):
try
:
is_new_pictorial
=
LikePictorialStat
.
objects
.
using
(
settings
.
SLAVE1_DB_NAME
)
.
filter
(
pictorial_id
=
pictorial_id
)
.
values_list
(
"is_new_pictorial"
,
flat
=
True
)
.
first
()
if
is_new_pictorial
==
0
:
return
False
else
:
return
True
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
True
@classmethod
def
get_pictorial_ctr_30
(
cls
,
pictorial_id
):
try
:
pictorial_ctr_30
=
LikePictorialStat
.
objects
.
using
(
settings
.
SLAVE1_DB_NAME
)
.
filter
(
pictorial_id
=
pictorial_id
)
.
values_list
(
"pictorial_ctr_30"
,
flat
=
True
)
.
first
()
return
pictorial_ctr_30
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
0.0
@classmethod
def
get_pictorial_like_rate_30
(
cls
,
pictorial_id
):
try
:
like_rate_30
=
LikePictorialStat
.
objects
.
using
(
settings
.
SLAVE1_DB_NAME
)
.
filter
(
pictorial_id
=
pictorial_id
)
.
values_list
(
"like_rate_30"
,
flat
=
True
)
.
first
()
return
like_rate_30
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
0.0
@classmethod
def
get_pictorial_ctr_all
(
cls
,
pictorial_id
):
try
:
pictorial_ctr_all
=
LikePictorialStat
.
objects
.
using
(
settings
.
SLAVE1_DB_NAME
)
.
filter
(
pictorial_id
=
pictorial_id
)
.
values_list
(
"pictorial_ctr_all"
,
flat
=
True
)
.
first
()
return
pictorial_ctr_all
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
0.0
@classmethod
def
get_pictorial_like_rate_all
(
cls
,
pictorial_id
):
try
:
like_rate_all
=
LikePictorialStat
.
objects
.
using
(
settings
.
SLAVE1_DB_NAME
)
.
filter
(
pictorial_id
=
pictorial_id
)
.
values_list
(
"like_rate_all"
,
flat
=
True
)
.
first
()
return
like_rate_all
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
0.0
trans2es/utils/pictorial_transfer.py
View file @
ff979cae
...
...
@@ -6,6 +6,7 @@ import logging
import
traceback
from
libs.tools
import
tzlc
from
trans2es.models.topic
import
Topic
from
trans2es.models.portrait_stat
import
LikePictorialStat
class
PictorialTransfer
(
object
):
...
...
@@ -75,6 +76,11 @@ class PictorialTransfer(object):
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"
])
res
[
"is_new_pictorial"
]
=
LikePictorialStat
.
get_pictorial_is_new
(
instance
.
id
)
res
[
"pictorial_ctr_30"
]
=
LikePictorialStat
.
get_pictorial_ctr_30
(
instance
.
id
)
res
[
"like_rate_30"
]
=
LikePictorialStat
.
get_pictorial_like_rate_30
(
instance
.
id
)
res
[
"pictorial_ctr_all"
]
=
LikePictorialStat
.
get_pictorial_ctr_all
(
instance
.
id
)
res
[
"like_rate_all"
]
=
LikePictorialStat
.
get_pictorial_like_rate_all
(
instance
.
id
)
logging
.
info
(
"get data:
%
s"
%
res
)
return
res
except
:
...
...
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