Commit 08faa42d authored by lixiaofang's avatar lixiaofang

add

parent 2ec7bbc9
......@@ -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
......@@ -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:
......
......@@ -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)
......
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