Commit b5a23082 authored by 高雅喆's avatar 高雅喆

es pictorial update

parent 82c67b7b
......@@ -46,6 +46,9 @@ class LikePictorialStat(models.Model):
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):
......@@ -79,3 +82,25 @@ class LikePictorialStat(models.Model):
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
......@@ -79,6 +79,8 @@ class PictorialTransfer(object):
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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment