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
7ac7ea25
Commit
7ac7ea25
authored
Sep 25, 2019
by
高雅喆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
问题索引增加字段
parent
b76b0b30
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
1 deletion
+59
-1
pictorial.json
trans2es/mapping/pictorial.json
+3
-0
portrait_stat.py
trans2es/models/portrait_stat.py
+52
-1
pictorial_transfer.py
trans2es/utils/pictorial_transfer.py
+4
-0
No files found.
trans2es/mapping/pictorial.json
View file @
7ac7ea25
...
...
@@ -4,6 +4,9 @@
"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"
},
"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 @
7ac7ea25
import
logging
import
traceback
from
django.db
import
models
from
django.conf
import
settings
class
LikeDeviceTagStat
(
models
.
Model
):
...
...
@@ -20,7 +23,7 @@ class LikeDeviceTagStat(models.Model):
class
LikeTopicStat
(
models
.
Model
):
class
Meta
:
verbose_name
=
u"30天内回答的stat"
db_table
=
"like_topic_stat
"
db_table
=
"like_topic_stat"
id
=
models
.
IntegerField
(
primary_key
=
True
,
verbose_name
=
u"主键ID"
)
create_time
=
models
.
DateTimeField
(
verbose_name
=
u'统计创建时间'
)
...
...
@@ -29,3 +32,50 @@ 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天内问题的点赞率"
)
@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
()
return
is_new_pictorial
[
0
]
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
""
@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
[
0
]
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
""
@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
[
0
]
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
""
\ No newline at end of file
trans2es/utils/pictorial_transfer.py
View file @
7ac7ea25
...
...
@@ -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,9 @@ 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
)
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