From a32d01b56415d18f2f637647ec695a5b3bb9cfe8 Mon Sep 17 00:00:00 2001 From: xieshen <1397910458@qq.com> Date: Fri, 23 Oct 2020 12:04:33 +0800 Subject: [PATCH] =?UTF-8?q?#=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dashboard/models.py | 6 +- dashboard/templates/dashboard/index.html | 108 ++++++++++-------- .../comment-on-interactive-monitoring.html | 58 +++++----- .../monitor/timeliness-monitoring.html | 18 +-- monitor/views.py | 30 ++++- 5 files changed, 128 insertions(+), 92 deletions(-) diff --git a/dashboard/models.py b/dashboard/models.py index 5dd178d..c296895 100644 --- a/dashboard/models.py +++ b/dashboard/models.py @@ -708,11 +708,11 @@ class TimelinessMonitoring(models.Model): counties = models.CharField('县区',max_length=256,null=True,blank=True) remark = models.CharField('备注',max_length=256,null=True,blank=True) results = models.CharField('监测结果',max_length=256,null=True,blank=True) - update = models.CharField('更新次数',max_length=256,null=True,blank=True) - silet = models.CharField('最大连续静默日数',max_length=256,null= True,blank=True) + update = models.IntegerField('更新次数',max_length=256,null=True,blank=True) + silet = models.IntegerField('最大连续静默日数',max_length=256,null= True,blank=True) start_data = models.CharField('开始时间',max_length=256,null=True,blank=True) end_data = models.CharField('结束时间',max_length=256,null=True,blank=True) - comment = models.CharField('评论次数',max_length=256,null=True,blank=True) + comment = models.IntegerField('评论次数',max_length=256,null=True,blank=True) date = models.CharField('最近更新时间',max_length=256,null=True,blank=True) def __str__(self): diff --git a/dashboard/templates/dashboard/index.html b/dashboard/templates/dashboard/index.html index e9dd389..ddd8808 100644 --- a/dashboard/templates/dashboard/index.html +++ b/dashboard/templates/dashboard/index.html @@ -78,70 +78,82 @@
-
- {# #} - - +
-
- {# #} - - +
-
- {# #} - -
-

{{ toutiao_count }}

- 今日头条 + +
+ {# #} + +
+

{{ toutiao_count }}

+ 今日头条 +
-
+
-
- {# #} - - +
-
- {# #} - -
-

{{ qita_count }}

- 其他新媒体 + +
+ {# #} + +
+

{{ qita_count }}

+ 其他新媒体 +
-
+
-
- {# #} - -
-

{{ organization_count }}

- 注册单位 + +
+ {# #} + +
+

{{ organization_count }}

+ 注册单位 +
-
+
diff --git a/monitor/templates/monitor/comment-on-interactive-monitoring.html b/monitor/templates/monitor/comment-on-interactive-monitoring.html index fb87d32..1ab8084 100644 --- a/monitor/templates/monitor/comment-on-interactive-monitoring.html +++ b/monitor/templates/monitor/comment-on-interactive-monitoring.html @@ -65,35 +65,35 @@
-
-
-
热点评论
-
- - - - - - - - - - - - - - - - - - - - -
新媒体类型账号名评论内容时间跟评数
{{ r.date }}{{ r.date }}{{ r.date }}{{ r.date }}{{ r.date }}
-
- -
-
+{#
#} +{#
#} +{#
热点评论
#} +{#
#} +{# #} +{# #} +{# #} +{# #} +{# #} +{# #} +{# #} +{# #} +{# #} +{# #} +{# #} +{# #} +{# #} +{# #} +{# #} +{# #} +{# #} +{# #} +{# #} +{# #} +{#
新媒体类型账号名评论内容时间跟评数
{{ r.date }}{{ r.date }}{{ r.date }}{{ r.date }}{{ r.date }}
#} +{#
#} +{##} +{#
#} +{#
#}
diff --git a/monitor/templates/monitor/timeliness-monitoring.html b/monitor/templates/monitor/timeliness-monitoring.html index 3c3d6ba..6d477f9 100644 --- a/monitor/templates/monitor/timeliness-monitoring.html +++ b/monitor/templates/monitor/timeliness-monitoring.html @@ -25,15 +25,15 @@

内容更新次数

-

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):