diff --git a/dashboard/models.py b/dashboard/models.py index b3c83f6..9f739ee 100644 --- a/dashboard/models.py +++ b/dashboard/models.py @@ -738,12 +738,12 @@ 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) + update = models.IntegerField('更新次数', null=True, blank=True) silet = models.CharField('最大连续静默日数', 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('评论次数', null=True, blank=True) date = models.CharField('最近更新时间', max_length=256, null=True, blank=True) def __str__(self): diff --git a/dashboard/templates/dashboard/base/left.html b/dashboard/templates/dashboard/base/left.html index 9827996..6d1bba7 100644 --- a/dashboard/templates/dashboard/base/left.html +++ b/dashboard/templates/dashboard/base/left.html @@ -41,8 +41,8 @@ {#
  • #} -
  • - +
  • + 时效性监测 {# #} @@ -215,4 +215,4 @@ -{% endwith %} \ No newline at end of file +{% endwith %} diff --git a/dashboard/templates/dashboard/paginator/timeliness-monitoring.html b/dashboard/templates/dashboard/paginator/timeliness-monitoring.html new file mode 100644 index 0000000..5971fd9 --- /dev/null +++ b/dashboard/templates/dashboard/paginator/timeliness-monitoring.html @@ -0,0 +1,18 @@ +
    + +
    diff --git a/management/templates/management/user-management.html b/management/templates/management/user-management.html index 09a6bd6..94503e1 100644 --- a/management/templates/management/user-management.html +++ b/management/templates/management/user-management.html @@ -51,7 +51,7 @@ 序号 头像 姓名 - 电话 + 电话^ 单位名称 {# 单位类型#} 行政区划 diff --git a/management/urls.py b/management/urls.py index 77765c3..abb5e8b 100644 --- a/management/urls.py +++ b/management/urls.py @@ -5,6 +5,7 @@ from management import views urlpatterns = [ # 用户管理 path('user/management/', views.user_management, name='user-management-management'), + path('user/management/?sort=username/', views.user_management, name='user-management-management-sort'), path('user/delete//', views.user_delete, name='user-management-delete'), path('user/update//', views.user_update, name='user-management-update'), # 矩阵管理 diff --git a/monitor/templates/monitor/new-media-public-opinion-weixin.html b/monitor/templates/monitor/new-media-public-opinion-weixin.html index d846676..6635801 100644 --- a/monitor/templates/monitor/new-media-public-opinion-weixin.html +++ b/monitor/templates/monitor/new-media-public-opinion-weixin.html @@ -76,7 +76,7 @@ 公众号 - 封面 +{# 封面#} 标题 评论数 回复数 @@ -87,8 +87,8 @@ {% for r in res %} {{ r.code }} - +{# #} {{ r.title }} {{ r.comment }} {{ r.reply }} diff --git a/monitor/templates/monitor/timeliness-monitoring-douyin.html b/monitor/templates/monitor/timeliness-monitoring-douyin.html new file mode 100644 index 0000000..306c8cd --- /dev/null +++ b/monitor/templates/monitor/timeliness-monitoring-douyin.html @@ -0,0 +1,208 @@ +{% extends 'dashboard/base/base.html' %} +{% load static %} +{% block content %} + +
    +
    + {% include 'dashboard/base/left.html' %} +
    +
    +
    + {% if messages %} + + {% endif %} +
    +
    + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + {% for r in res %} + + + + + + + + + + + + {% endfor %} + +
    抖音号更新次数最近更新时间连续未更新天数评论次数评论回复次数错别字个数敏感词个数非法外链接
    {{ r.n_name }}{{ r.count }}{{ r.start_data }}{{ r.silet }}00{{ r.wrongly }}00
    + +
    +
    +
    + +
    + +{% endblock %} +{% block add_js %} + + + +{% endblock %} diff --git a/monitor/templates/monitor/timeliness-monitoring-qita.html b/monitor/templates/monitor/timeliness-monitoring-qita.html new file mode 100644 index 0000000..b992d5e --- /dev/null +++ b/monitor/templates/monitor/timeliness-monitoring-qita.html @@ -0,0 +1,210 @@ +{% extends 'dashboard/base/base.html' %} +{% load static %} +{% block content %} + +
    +
    + {% include 'dashboard/base/left.html' %} +
    +
    +
    + {% if messages %} + + {% endif %} +
    +
    + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + + {% for r in res %} + + + + + + + + + + + + + {% endfor %} + +
    新媒体类型新媒体账号更新次数最近更新时间连续未更新天数评论次数评论回复次数错别字个数敏感词个数非法外链接
    {{ r.n_type }}{{ r.n_name }}{{ r.count }}{{ r.start_data }}{{ r.silet }}00{{ r.wrongly }}00
    + +
    +
    +
    + +
    + +{% endblock %} +{% block add_js %} + + + +{% endblock %} diff --git a/monitor/templates/monitor/timeliness-monitoring-toutiao.html b/monitor/templates/monitor/timeliness-monitoring-toutiao.html new file mode 100644 index 0000000..38a468a --- /dev/null +++ b/monitor/templates/monitor/timeliness-monitoring-toutiao.html @@ -0,0 +1,208 @@ +{% extends 'dashboard/base/base.html' %} +{% load static %} +{% block content %} + +
    +
    + {% include 'dashboard/base/left.html' %} +
    +
    +
    + {% if messages %} + + {% endif %} +
    +
    + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + {% for r in res %} + + + + + + + + + + + + {% endfor %} + +
    头条号更新次数最近更新时间连续未更新天数评论次数评论回复次数错别字个数敏感词个数非法外链接
    {{ r.n_name }}{{ r.count }}{{ r.start_data }}{{ r.silet }}00{{ r.wrongly }}00
    + +
    +
    +
    + +
    + +{% endblock %} +{% block add_js %} + + + +{% endblock %} diff --git a/monitor/templates/monitor/timeliness-monitoring-weibo.html b/monitor/templates/monitor/timeliness-monitoring-weibo.html new file mode 100644 index 0000000..6722ad1 --- /dev/null +++ b/monitor/templates/monitor/timeliness-monitoring-weibo.html @@ -0,0 +1,208 @@ +{% extends 'dashboard/base/base.html' %} +{% load static %} +{% block content %} + +
    +
    + {% include 'dashboard/base/left.html' %} +
    +
    +
    + {% if messages %} + + {% endif %} +
    +
    + +
    +
    +
    + +
    +
    + +
    + + + + + + + + + + + + + + + + {% for r in res %} + + + + + + + + + + + + {% endfor %} + +
    微博号更新次数最近更新时间连续未更新天数评论次数评论回复次数错别字个数敏感词个数非法外链接
    {{ r.n_name }}{{ r.count }}{{ r.start_data }}{{ r.silet }}00{{ r.wrongly }}00
    + +
    +
    +
    + +
    + +{% endblock %} +{% block add_js %} + + + +{% endblock %} diff --git a/monitor/templates/monitor/timeliness-monitoring.html b/monitor/templates/monitor/timeliness-monitoring-weixin.html similarity index 83% rename from monitor/templates/monitor/timeliness-monitoring.html rename to monitor/templates/monitor/timeliness-monitoring-weixin.html index 6d477f9..b6ac533 100644 --- a/monitor/templates/monitor/timeliness-monitoring.html +++ b/monitor/templates/monitor/timeliness-monitoring-weixin.html @@ -34,24 +34,24 @@

    内容更新次数

    {{ update_count }}

    -

    本周新增次数

    -

    本月新增次数

    +

    本周新增次数0

    +

    本月新增次数0

    @@ -79,14 +79,14 @@
    @@ -94,6 +94,7 @@ 公众号 + 更新次数 最近更新时间 连续未更新天数 评论次数 @@ -104,20 +105,24 @@ + {% for r in res %} - {{ r.code }} - + {{ r.n_name }} {{ r.count }} - {{ r.count_jc }} - {{ r.comment }} - {{ r.reply }} - {{ r.date }} - {{ r.date }} + {{ r.start_data }} + {{ r.silet }} + 0 + 0 + {{ r.wrongly }} + 0 + 0 + {% endfor %} + diff --git a/monitor/urls.py b/monitor/urls.py index 48898ac..4bb79fa 100644 --- a/monitor/urls.py +++ b/monitor/urls.py @@ -10,7 +10,11 @@ urlpatterns = [ path('new/media/public/opinion/douyin/',views.new_media_public_opinion_douyin,name='monitor-new-media-public-opinion-douyin'), path('new/media/public/opinion/qita/',views.new_media_public_opinion_qita,name='monitor-new-media-public-opinion-qita'), #时效性监测 - path('timeliness/monitoring/',views.timeliness_monitoring,name='monitor-timeliness-monitoring'), + path('timeliness/monitoring/weixin/',views.timeliness_monitoring_weixin,name='monitor-timeliness-monitoring-weixin'), + path('timeliness/monitoring/weibo/',views.timeliness_monitoring_weibo,name='monitor-timeliness-monitoring-weibo'), + path('timeliness/monitoring/toutiao/',views.timeliness_monitoring_toutiao,name='monitor-timeliness-monitoring-toutiao'), + path('timeliness/monitoring/douyin/',views.timeliness_monitoring_douyin,name='monitor-timeliness-monitoring-douyin'), + path('timeliness/monitoring/qita/',views.timeliness_monitoring_qita,name='monitor-timeliness-monitoring-qita'), #错别字监测 path('error/monitoring/',views.error_monitoring,name='monitor-error-monitoring'), #敏感词监测 diff --git a/monitor/views.py b/monitor/views.py index 35b0f4c..3d3aa8d 100644 --- a/monitor/views.py +++ b/monitor/views.py @@ -4,6 +4,7 @@ import json from collections import Counter import jieba +from django.core.paginator import Paginator, PageNotAnInteger, EmptyPage from django.db.models import Sum from django.http import HttpResponse from django.shortcuts import render @@ -23,7 +24,6 @@ def new_media_public_opinion_weixin(request): o = dict() o['id'] = str(w.id) o['code'] = w.weixin.code - o['image'] = w.weixin.image o['title'] = w.title o['comment'] = w.comment o['reply'] = w.reply @@ -120,7 +120,7 @@ def new_media_public_opinion_qita(request): return render(request, 'monitor/new-media-public-opinion-qita.html', {'res': res, 'qita': qita, 'group': group}) -def timeliness_monitoring(request): +def timeliness_monitoring_weixin(request): now = datetime.datetime.now() # 本周第一天和最后一天 this_week_start = now - timedelta(days=now.weekday()) @@ -129,21 +129,370 @@ def timeliness_monitoring(request): 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'] + # 新媒体数量 + 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().aggregate(nums=Sum('update'))['nums'] + # update_count_month = TimelinessMonitoring.objects.filter(created__range=(this_month_start,this_month_end)).aggregate(nums=Sum('update'))['nums'] + # update_count_week = TimelinessMonitoring.objects.filter(created__range=(this_week_start,this_week_end)).aggregate(nums=Sum('update'))['nums'] - - # comment = TimelinessMonitoring.objects.all().aggregate(nums=Sum('comment')) - # comment_count = comment['nums'] + comment_count = TimelinessMonitoring.objects.all().aggregate(nums=Sum('comment'))['nums'] wrongly_count = Wrongly.objects.all().count sensitive_count = None organization_count = Organization.objects.all().count() + organization_count_month = Organization.objects.filter(created__range=(this_month_start, this_month_end)).count() + organization_count_week = Organization.objects.filter(created__range=(this_week_start, this_week_end)).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,'wrongly_count':wrongly_count,'organization_count':organization_count}) + timelinessmonitoring = TimelinessMonitoring.objects.filter(n_type='微信').order_by('n_name') + res = [] + + if timelinessmonitoring is not None: + paginator = Paginator(timelinessmonitoring, 6) + page = int(request.GET.get('page', 1)) + try: + timelinessmonitoring = paginator.page(page) + except PageNotAnInteger: + timelinessmonitoring = paginator.page(1) + except EmptyPage: + timelinessmonitoring = paginator.page(paginator.num_pages) + for t in timelinessmonitoring: + o = dict() + o['n_type'] = t.n_type + o['count'] = TimelinessMonitoring.objects.filter(n_name=t.n_name).aggregate(nums=Sum('update'))['nums'] + o['n_name'] = t.n_name + o['o_type'] = t.o_type + o['o_name'] = t.o_name + o['city'] = t.city + o['counties'] = t.counties + o['remark'] = t.remark + o['results'] = t.results + o['update'] = t.update + o['silet'] = t.silet + o['start_data'] = t.start_data + o['end_data'] = t.end_data + o['comment'] = t.comment + o['date'] = t.date + o['wrongly'] = Wrongly.objects.filter(n_name=t.n_name).count() + res.append(o) + + return render(request, 'monitor/timeliness-monitoring-weixin.html', + {'new_media_count': new_media_count, 'new_media_count_month': new_media_count_month, + 'new_media_count_week': new_media_count_week, 'wrongly_count': wrongly_count, + 'organization_count': organization_count, 'update_count': update_count, + 'comment_count': comment_count, 'organization_count_month': organization_count_month, + 'organization_count_week': organization_count_week, 'res': res, + 'timelinessmonitoring': timelinessmonitoring}) + + +def timeliness_monitoring_weibo(request): + 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().aggregate(nums=Sum('update'))['nums'] + # update_count_month = TimelinessMonitoring.objects.filter(created__range=(this_month_start,this_month_end)).aggregate(nums=Sum('update'))['nums'] + # update_count_week = TimelinessMonitoring.objects.filter(created__range=(this_week_start,this_week_end)).aggregate(nums=Sum('update'))['nums'] + + comment_count = TimelinessMonitoring.objects.all().aggregate(nums=Sum('comment'))['nums'] + wrongly_count = Wrongly.objects.all().count + sensitive_count = None + organization_count = Organization.objects.all().count() + organization_count_month = Organization.objects.filter(created__range=(this_month_start, this_month_end)).count() + organization_count_week = Organization.objects.filter(created__range=(this_week_start, this_week_end)).count() + + timelinessmonitoring = TimelinessMonitoring.objects.filter(n_type='微博').order_by('n_name') + res = [] + + if timelinessmonitoring is not None: + paginator = Paginator(timelinessmonitoring, 6) + page = int(request.GET.get('page', 1)) + try: + timelinessmonitoring = paginator.page(page) + except PageNotAnInteger: + timelinessmonitoring = paginator.page(1) + except EmptyPage: + timelinessmonitoring = paginator.page(paginator.num_pages) + for t in timelinessmonitoring: + o = dict() + o['n_type'] = t.n_type + o['count'] = TimelinessMonitoring.objects.filter(n_name=t.n_name).aggregate(nums=Sum('update'))['nums'] + o['n_name'] = t.n_name + o['o_type'] = t.o_type + o['o_name'] = t.o_name + o['city'] = t.city + o['counties'] = t.counties + o['remark'] = t.remark + o['results'] = t.results + o['update'] = t.update + o['silet'] = t.silet + o['start_data'] = t.start_data + o['end_data'] = t.end_data + o['comment'] = t.comment + o['date'] = t.date + o['wrongly'] = Wrongly.objects.filter(n_name=t.n_name).count() + res.append(o) + + return render(request, 'monitor/timeliness-monitoring-weibo.html', + {'new_media_count': new_media_count, 'new_media_count_month': new_media_count_month, + 'new_media_count_week': new_media_count_week, 'wrongly_count': wrongly_count, + 'organization_count': organization_count, 'update_count': update_count, + 'comment_count': comment_count, 'organization_count_month': organization_count_month, + 'organization_count_week': organization_count_week, 'res': res, + 'timelinessmonitoring': timelinessmonitoring}) + + +def timeliness_monitoring_toutiao(request): + 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().aggregate(nums=Sum('update'))['nums'] + # update_count_month = TimelinessMonitoring.objects.filter(created__range=(this_month_start,this_month_end)).aggregate(nums=Sum('update'))['nums'] + # update_count_week = TimelinessMonitoring.objects.filter(created__range=(this_week_start,this_week_end)).aggregate(nums=Sum('update'))['nums'] + + comment_count = TimelinessMonitoring.objects.all().aggregate(nums=Sum('comment'))['nums'] + wrongly_count = Wrongly.objects.all().count + sensitive_count = None + organization_count = Organization.objects.all().count() + organization_count_month = Organization.objects.filter(created__range=(this_month_start, this_month_end)).count() + organization_count_week = Organization.objects.filter(created__range=(this_week_start, this_week_end)).count() + + timelinessmonitoring = TimelinessMonitoring.objects.filter(n_type='今日头条').order_by('n_name') + res = [] + + if timelinessmonitoring is not None: + paginator = Paginator(timelinessmonitoring, 6) + page = int(request.GET.get('page', 1)) + try: + timelinessmonitoring = paginator.page(page) + except PageNotAnInteger: + timelinessmonitoring = paginator.page(1) + except EmptyPage: + timelinessmonitoring = paginator.page(paginator.num_pages) + for t in timelinessmonitoring: + o = dict() + o['n_type'] = t.n_type + o['count'] = TimelinessMonitoring.objects.filter(n_name=t.n_name).aggregate(nums=Sum('update'))['nums'] + o['n_name'] = t.n_name + o['o_type'] = t.o_type + o['o_name'] = t.o_name + o['city'] = t.city + o['counties'] = t.counties + o['remark'] = t.remark + o['results'] = t.results + o['update'] = t.update + o['silet'] = t.silet + o['start_data'] = t.start_data + o['end_data'] = t.end_data + o['comment'] = t.comment + o['date'] = t.date + o['wrongly'] = Wrongly.objects.filter(n_name=t.n_name).count() + res.append(o) + + return render(request, 'monitor/timeliness-monitoring-toutiao.html', + {'new_media_count': new_media_count, 'new_media_count_month': new_media_count_month, + 'new_media_count_week': new_media_count_week, 'wrongly_count': wrongly_count, + 'organization_count': organization_count, 'update_count': update_count, + 'comment_count': comment_count, 'organization_count_month': organization_count_month, + 'organization_count_week': organization_count_week, 'res': res, + 'timelinessmonitoring': timelinessmonitoring}) + + +def timeliness_monitoring_douyin(request): + 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().aggregate(nums=Sum('update'))['nums'] + # update_count_month = TimelinessMonitoring.objects.filter(created__range=(this_month_start,this_month_end)).aggregate(nums=Sum('update'))['nums'] + # update_count_week = TimelinessMonitoring.objects.filter(created__range=(this_week_start,this_week_end)).aggregate(nums=Sum('update'))['nums'] + + comment_count = TimelinessMonitoring.objects.all().aggregate(nums=Sum('comment'))['nums'] + wrongly_count = Wrongly.objects.all().count + sensitive_count = None + organization_count = Organization.objects.all().count() + organization_count_month = Organization.objects.filter(created__range=(this_month_start, this_month_end)).count() + organization_count_week = Organization.objects.filter(created__range=(this_week_start, this_week_end)).count() + + timelinessmonitoring = TimelinessMonitoring.objects.filter(n_type__contains='抖音').order_by('n_name') + res = [] + + if timelinessmonitoring is not None: + paginator = Paginator(timelinessmonitoring, 6) + page = int(request.GET.get('page', 1)) + try: + timelinessmonitoring = paginator.page(page) + except PageNotAnInteger: + timelinessmonitoring = paginator.page(1) + except EmptyPage: + timelinessmonitoring = paginator.page(paginator.num_pages) + for t in timelinessmonitoring: + o = dict() + o['n_type'] = t.n_type + o['count'] = TimelinessMonitoring.objects.filter(n_name=t.n_name).aggregate(nums=Sum('update'))['nums'] + o['n_name'] = t.n_name + o['o_type'] = t.o_type + o['o_name'] = t.o_name + o['city'] = t.city + o['counties'] = t.counties + o['remark'] = t.remark + o['results'] = t.results + o['update'] = t.update + o['silet'] = t.silet + o['start_data'] = t.start_data + o['end_data'] = t.end_data + o['comment'] = t.comment + o['date'] = t.date + o['wrongly'] = Wrongly.objects.filter(n_name=t.n_name).count() + res.append(o) + + return render(request, 'monitor/timeliness-monitoring-douyin.html', + {'new_media_count': new_media_count, 'new_media_count_month': new_media_count_month, + 'new_media_count_week': new_media_count_week, 'wrongly_count': wrongly_count, + 'organization_count': organization_count, 'update_count': update_count, + 'comment_count': comment_count, 'organization_count_month': organization_count_month, + 'organization_count_week': organization_count_week, 'res': res, + 'timelinessmonitoring': timelinessmonitoring}) + + +def timeliness_monitoring_qita(request): + 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().aggregate(nums=Sum('update'))['nums'] + # update_count_month = TimelinessMonitoring.objects.filter(created__range=(this_month_start,this_month_end)).aggregate(nums=Sum('update'))['nums'] + # update_count_week = TimelinessMonitoring.objects.filter(created__range=(this_week_start,this_week_end)).aggregate(nums=Sum('update'))['nums'] + + comment_count = TimelinessMonitoring.objects.all().aggregate(nums=Sum('comment'))['nums'] + wrongly_count = Wrongly.objects.all().count + sensitive_count = None + organization_count = Organization.objects.all().count() + organization_count_month = Organization.objects.filter(created__range=(this_month_start, this_month_end)).count() + organization_count_week = Organization.objects.filter(created__range=(this_week_start, this_week_end)).count() + + timelinessmonitoring = TimelinessMonitoring.objects.exclude(n_type__in=['微信','微博','今日头条','抖音']).order_by('n_name') + res = [] + + if timelinessmonitoring is not None: + paginator = Paginator(timelinessmonitoring, 6) + page = int(request.GET.get('page', 1)) + try: + timelinessmonitoring = paginator.page(page) + except PageNotAnInteger: + timelinessmonitoring = paginator.page(1) + except EmptyPage: + timelinessmonitoring = paginator.page(paginator.num_pages) + for t in timelinessmonitoring: + o = dict() + o['n_type'] = t.n_type + o['count'] = TimelinessMonitoring.objects.filter(n_name=t.n_name).aggregate(nums=Sum('update'))['nums'] + o['n_name'] = t.n_name + o['o_type'] = t.o_type + o['o_name'] = t.o_name + o['city'] = t.city + o['counties'] = t.counties + o['remark'] = t.remark + o['results'] = t.results + o['update'] = t.update + o['silet'] = t.silet + o['start_data'] = t.start_data + o['end_data'] = t.end_data + o['comment'] = t.comment + o['date'] = t.date + o['wrongly'] = Wrongly.objects.filter(n_name=t.n_name).count() + res.append(o) + + return render(request, 'monitor/timeliness-monitoring-qita.html', + {'new_media_count': new_media_count, 'new_media_count_month': new_media_count_month, + 'new_media_count_week': new_media_count_week, 'wrongly_count': wrongly_count, + 'organization_count': organization_count, 'update_count': update_count, + 'comment_count': comment_count, 'organization_count_month': organization_count_month, + 'organization_count_week': organization_count_week, 'res': res, + 'timelinessmonitoring': timelinessmonitoring}) def error_monitoring(request): @@ -187,8 +536,7 @@ def comment_on_interactive_monitoring_json(request): def monitoring_report(request): news = News.objects.filter(type='3').order_by('-date') count = News.objects.filter(type='3').count() - return render(request, 'monitor/monitoring-report.html', {'news': news,'count':count}) - + return render(request, 'monitor/monitoring-report.html', {'news': news, 'count': count}) def test(request):