新媒体类型 | -账号名 | -评论内容 | -时间 | -跟评数 | -
---|---|---|---|---|
{{ r.date }} | -{{ r.date }} | -{{ r.date }} | -{{ r.date }} | -{{ r.date }} | -
新媒体类型 | #} +{#账号名 | #} +{#评论内容 | #} +{#时间 | #} +{#跟评数 | #} +{#
---|---|---|---|---|
{{ r.date }} | #} +{#{{ r.date }} | #} +{#{{ r.date }} | #} +{#{{ r.date }} | #} +{#{{ r.date }} | #} +{#
内容更新次数
-288
+{{ update_count }}
本周新增次数
本月新增次数
@@ -57,14 +57,14 @@新媒体数量
+ +主体数量
288
本周新增
本月新增
diff --git a/monitor/views.py b/monitor/views.py index 9351a02..790490d 100644 --- a/monitor/views.py +++ b/monitor/views.py @@ -1,14 +1,16 @@ import csv +import datetime import json from collections import Counter import jieba +from django.db.models import Sum from django.http import HttpResponse from django.shortcuts import render - +from datetime import timedelta # Create your views here. from dashboard.models import Weixin, Weixin_data, Toutiao_data, Weibo_data, Qita_jc, Group, Toutiao, Weibo, Qita, \ - Douyin, Douyin_data, News + Douyin, Douyin_data, News, TimelinessMonitoring, Organization, Wrongly from monitor.models import Test @@ -119,7 +121,29 @@ def new_media_public_opinion_qita(request): def timeliness_monitoring(request): - return render(request, 'monitor/timeliness-monitoring.html') + now = datetime.datetime.now() + # 本周第一天和最后一天 + this_week_start = now - timedelta(days=now.weekday()) + this_week_end = now + timedelta(days=6 - now.weekday()) + # 本月第一天和最后一天 + this_month_start = datetime.datetime(now.year, now.month, 1) + this_month_end = datetime.datetime(now.year, now.month + 1, 1) - timedelta(days=1) + datetime.timedelta( + hours=23, minutes=59, seconds=59) + new_media_count = int(Weixin.objects.all().count())+int(Weibo.objects.all().count())+int(Toutiao.objects.all().count())+int(Douyin.objects.all().count())+int(Qita.objects.all().count()) + new_media_count_month =int(Weixin.objects.filter(created__range=(this_month_start,this_month_end)).count())+int(Weibo.objects.filter(created__range=(this_month_start,this_month_end)).count())+int(Toutiao.objects.filter(created__range=(this_month_start,this_month_end)).count())+int(Douyin.objects.filter(created__range=(this_month_start,this_month_end)).count())+int(Qita.objects.filter(created__range=(this_month_start,this_month_end)).count()) + new_media_count_week =int(Weixin.objects.filter(created__range=(this_week_start,this_week_end)).count())+int(Weibo.objects.filter(created__range=(this_week_start,this_week_end)).count())+int(Toutiao.objects.filter(created__range=(this_week_start,this_week_end)).count())+int(Douyin.objects.filter(created__range=(this_week_start,this_week_end)).count())+int(Qita.objects.filter(created__range=(this_week_start,this_week_end)).count()) + # update_count = TimelinessMonitoring.objects.all().count() + update = TimelinessMonitoring.objects.all().aggregate(nums=Sum('update')) + update_count = update['nums'] + + + comment = TimelinessMonitoring.objects.all().aggregate(nums=Sum('comment')) + comment_count = comment['nums'] + wrongly_count = Wrongly.objects.all().count + sensitive_count = None + organization_count = Organization.objects.all().count() + + return render(request, 'monitor/timeliness-monitoring.html',{'new_media_count':new_media_count,'new_media_count_month':new_media_count_month,'new_media_count_week':new_media_count_week,'update_count':update_count,'comment_count':comment_count,'wrongly_count':wrongly_count,'organization_count':organization_count}) def error_monitoring(request):