Merge branch 'master' of http://210.77.77.77/xieshen/newmediamonitoring
This commit is contained in:
commit
788750aa0a
|
@ -227,34 +227,39 @@ class NewMedia(models.Model):
|
||||||
@classmethod
|
@classmethod
|
||||||
def category_one_count(cls):
|
def category_one_count(cls):
|
||||||
t1 = Weixin.objects.exclude(
|
t1 = Weixin.objects.exclude(
|
||||||
|
status=0,
|
||||||
organization__province=''
|
organization__province=''
|
||||||
).filter(
|
).filter(
|
||||||
organization__cities='',
|
organization__cities='',
|
||||||
organization__district=''
|
organization__district='',
|
||||||
).count()
|
).count()
|
||||||
t2 = Weibo.objects.exclude(
|
t2 = Weibo.objects.exclude(
|
||||||
|
status=0,
|
||||||
organization__province=''
|
organization__province=''
|
||||||
).filter(
|
).filter(
|
||||||
organization__cities='',
|
organization__cities='',
|
||||||
organization__district=''
|
organization__district='',
|
||||||
).count()
|
).count()
|
||||||
t3 = Toutiao.objects.exclude(
|
t3 = Toutiao.objects.exclude(
|
||||||
|
status=0,
|
||||||
organization__province=''
|
organization__province=''
|
||||||
).filter(
|
).filter(
|
||||||
organization__cities='',
|
organization__cities='',
|
||||||
organization__district=''
|
organization__district='',
|
||||||
).count()
|
).count()
|
||||||
t4 = Douyin.objects.exclude(
|
t4 = Douyin.objects.exclude(
|
||||||
|
status=0,
|
||||||
organization__province=''
|
organization__province=''
|
||||||
).filter(
|
).filter(
|
||||||
organization__cities='',
|
organization__cities='',
|
||||||
organization__district=''
|
organization__district='',
|
||||||
).count()
|
).count()
|
||||||
t5 = Qita.objects.exclude(
|
t5 = Qita.objects.exclude(
|
||||||
|
status=0,
|
||||||
organization__province=''
|
organization__province=''
|
||||||
).filter(
|
).filter(
|
||||||
organization__cities='',
|
organization__cities='',
|
||||||
organization__district=''
|
organization__district='',
|
||||||
).count()
|
).count()
|
||||||
return t1 + t2 + t3 + t4 + t5
|
return t1 + t2 + t3 + t4 + t5
|
||||||
|
|
||||||
|
@ -262,59 +267,69 @@ class NewMedia(models.Model):
|
||||||
def category_two_count(cls):
|
def category_two_count(cls):
|
||||||
t1 = Weixin.objects.exclude(
|
t1 = Weixin.objects.exclude(
|
||||||
organization__province='',
|
organization__province='',
|
||||||
organization__cities=''
|
organization__cities='',
|
||||||
|
status=0
|
||||||
).filter(
|
).filter(
|
||||||
organization__district=''
|
organization__district='',
|
||||||
).count()
|
).count()
|
||||||
t2 = Weibo.objects.exclude(
|
t2 = Weibo.objects.exclude(
|
||||||
organization__province='',
|
organization__province='',
|
||||||
organization__cities=''
|
organization__cities='',
|
||||||
|
status=0
|
||||||
).filter(
|
).filter(
|
||||||
organization__district=''
|
organization__district='',
|
||||||
).count()
|
).count()
|
||||||
t3 = Toutiao.objects.exclude(
|
t3 = Toutiao.objects.exclude(
|
||||||
organization__province='',
|
organization__province='',
|
||||||
organization__cities=''
|
organization__cities='',
|
||||||
|
status=0
|
||||||
).filter(
|
).filter(
|
||||||
organization__district=''
|
organization__district='',
|
||||||
).count()
|
).count()
|
||||||
t4 = Douyin.objects.exclude(
|
t4 = Douyin.objects.exclude(
|
||||||
organization__province='',
|
organization__province='',
|
||||||
organization__cities=''
|
organization__cities='',
|
||||||
|
status=0
|
||||||
).filter(
|
).filter(
|
||||||
organization__district=''
|
organization__district='',
|
||||||
).count()
|
).count()
|
||||||
t5 = Qita.objects.exclude(
|
t5 = Qita.objects.exclude(
|
||||||
organization__province='',
|
organization__province='',
|
||||||
organization__cities=''
|
organization__cities='',
|
||||||
|
status=0
|
||||||
).filter(
|
).filter(
|
||||||
organization__district=''
|
organization__district='',
|
||||||
).count()
|
).count()
|
||||||
return t1 + t2 + t3 + t4 + t5
|
return t1 + t2 + t3 + t4 + t5
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def category_three_count(cls):
|
def category_three_count(cls):
|
||||||
t1 = Weixin.objects.exclude(
|
t1 = Weixin.objects.exclude(
|
||||||
|
status=0,
|
||||||
organization__province='',
|
organization__province='',
|
||||||
organization__cities='',
|
organization__cities='',
|
||||||
organization__district=''
|
organization__district=''
|
||||||
).count()
|
).count()
|
||||||
t2 = Weibo.objects.exclude(
|
t2 = Weibo.objects.exclude(
|
||||||
|
status=0,
|
||||||
organization__province='',
|
organization__province='',
|
||||||
organization__cities='',
|
organization__cities='',
|
||||||
organization__district=''
|
organization__district=''
|
||||||
).count()
|
).count()
|
||||||
t3 = Toutiao.objects.exclude(
|
t3 = Toutiao.objects.exclude(
|
||||||
|
status=0,
|
||||||
organization__province='',
|
organization__province='',
|
||||||
organization__cities='',
|
organization__cities='',
|
||||||
organization__district=''
|
organization__district=''
|
||||||
).count()
|
).count()
|
||||||
t4 = Douyin.objects.exclude(
|
t4 = Douyin.objects.exclude(
|
||||||
|
status=0,
|
||||||
organization__province='',
|
organization__province='',
|
||||||
organization__cities='',
|
organization__cities='',
|
||||||
organization__district=''
|
organization__district=''
|
||||||
).count()
|
).count()
|
||||||
t5 = Qita.objects.exclude(
|
t5 = Qita.objects.exclude(
|
||||||
|
status=0,
|
||||||
organization__province='',
|
organization__province='',
|
||||||
organization__cities='',
|
organization__cities='',
|
||||||
organization__district=''
|
organization__district=''
|
||||||
|
|
|
@ -45,6 +45,7 @@ urlpatterns = [
|
||||||
path('tasks/create_test/', views.create_test_task,
|
path('tasks/create_test/', views.create_test_task,
|
||||||
name='polls_tasks_create_test'),
|
name='polls_tasks_create_test'),
|
||||||
path('groups/list/', views.groups, name='polls_groups_list'),
|
path('groups/list/', views.groups, name='polls_groups_list'),
|
||||||
|
path('groups/pick/', views.pick_groups, name='polls_groups_pick'),
|
||||||
path('groups/level/', views.is_level1_or_leve2, name='polls_groups_level'),
|
path('groups/level/', views.is_level1_or_leve2, name='polls_groups_level'),
|
||||||
path('groups/test-room/', views.room, name='polls_group_test_room'),
|
path('groups/test-room/', views.room, name='polls_group_test_room'),
|
||||||
path('groups/manager/', views.group_manager, name='polls_groups_manager'),
|
path('groups/manager/', views.group_manager, name='polls_groups_manager'),
|
||||||
|
|
|
@ -4,7 +4,7 @@ from .media import medias, my_medias, create_media, update_media, media_detail,
|
||||||
from .news import news_list, news_top, news_detail
|
from .news import news_list, news_top, news_detail
|
||||||
from .monitor import monitor_statistics, monitor_result, media_statistics, city_ranking
|
from .monitor import monitor_statistics, monitor_result, media_statistics, city_ranking
|
||||||
from .task import tasks, create_task, create_test_task, get_task
|
from .task import tasks, create_task, create_test_task, get_task
|
||||||
from .group import groups, room, is_level1_or_leve2, group_member, group_manager, group_enter, group_leave
|
from .group import groups, room, is_level1_or_leve2, group_member, group_manager, group_enter, group_leave, pick_groups
|
||||||
from .compartment import compartments
|
from .compartment import compartments
|
||||||
from .organizations import organizations, organization_level
|
from .organizations import organizations, organization_level
|
||||||
from .message import last_messages, send_text_message, is_read_message, read_message
|
from .message import last_messages, send_text_message, is_read_message, read_message
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -47,6 +47,25 @@ def groups(request):
|
||||||
return JsonResponse({'status': 'success', 'message': results}, safe=False)
|
return JsonResponse({'status': 'success', 'message': results}, safe=False)
|
||||||
|
|
||||||
|
|
||||||
|
@csrf_exempt
|
||||||
|
@polls_login_required
|
||||||
|
def pick_groups(request):
|
||||||
|
if request.method == 'POST':
|
||||||
|
return HttpResponse(status=405)
|
||||||
|
user_id = request.user.id
|
||||||
|
category = request.GET.get('category')
|
||||||
|
q = Group.objects.filter(status=1, group_admin__user__id=user_id).distinct()
|
||||||
|
groups = q.filter(classify=category) if category else q
|
||||||
|
results = []
|
||||||
|
for o in groups:
|
||||||
|
result = dict()
|
||||||
|
result['id'] = str(o.id)
|
||||||
|
print(o.id, o.name)
|
||||||
|
result['name'] = o.name
|
||||||
|
result['image'] = request.build_absolute_uri(o.image.url)
|
||||||
|
results.append(result)
|
||||||
|
return JsonResponse({'status': 'success', 'message': results}, safe=False)
|
||||||
|
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
@polls_login_required
|
@polls_login_required
|
||||||
def group_manager(request):
|
def group_manager(request):
|
||||||
|
|
|
@ -26,11 +26,11 @@ COMPARTMENTS = {
|
||||||
|
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
def monitor_statistics(request):
|
def monitor_statistics(request):
|
||||||
wbc = Weibo.objects.count()
|
wbc = Weibo.objects.exclude(status=0).count()
|
||||||
wxc = Weixin.objects.count()
|
wxc = Weixin.objects.exclude(status=0).count()
|
||||||
ttc = Toutiao.objects.count()
|
ttc = Toutiao.objects.exclude(status=0).count()
|
||||||
qtc = Qita.objects.count()
|
qtc = Qita.objects.exclude(status=0).count()
|
||||||
dyc = Douyin.objects.count()
|
dyc = Douyin.objects.exclude(status=0).count()
|
||||||
total = wbc+wxc+ttc+qtc+dyc
|
total = wbc+wxc+ttc+qtc+dyc
|
||||||
|
|
||||||
chart1_data = []
|
chart1_data = []
|
||||||
|
@ -41,10 +41,12 @@ def monitor_statistics(request):
|
||||||
chart1_data.append({'name': '其它', 'value': qtc})
|
chart1_data.append({'name': '其它', 'value': qtc})
|
||||||
|
|
||||||
results = dict()
|
results = dict()
|
||||||
q = Weixin.objects.exclude(organization__cities='').values('organization__cities').order_by(
|
q = Weixin.objects.exclude(organization__cities='', status=0).values('organization__cities').order_by(
|
||||||
'organization__cities').annotate(num_media=Count('organization__cities'))
|
'organization__cities').annotate(num_media=Count('organization__cities'))
|
||||||
for row in q:
|
for row in q:
|
||||||
code = row['organization__cities']
|
code = row['organization__cities']
|
||||||
|
if not code:
|
||||||
|
continue
|
||||||
compartment = COMPARTMENTS[code]
|
compartment = COMPARTMENTS[code]
|
||||||
if code in results:
|
if code in results:
|
||||||
nums = results[compartment]
|
nums = results[compartment]
|
||||||
|
@ -52,10 +54,12 @@ def monitor_statistics(request):
|
||||||
else:
|
else:
|
||||||
results[compartment] = [row['num_media']]
|
results[compartment] = [row['num_media']]
|
||||||
|
|
||||||
q = Weibo.objects.exclude(organization__cities='').values('organization__cities').order_by(
|
q = Weibo.objects.exclude(organization__cities='', status=0).values('organization__cities').order_by(
|
||||||
'organization__cities').annotate(num_media=Count('organization__cities'))
|
'organization__cities').annotate(num_media=Count('organization__cities'))
|
||||||
for row in q:
|
for row in q:
|
||||||
code = row['organization__cities']
|
code = row['organization__cities']
|
||||||
|
if not code:
|
||||||
|
continue
|
||||||
compartment = COMPARTMENTS[code]
|
compartment = COMPARTMENTS[code]
|
||||||
if compartment in results:
|
if compartment in results:
|
||||||
nums = results[compartment]
|
nums = results[compartment]
|
||||||
|
@ -63,10 +67,12 @@ def monitor_statistics(request):
|
||||||
else:
|
else:
|
||||||
results[compartment] = [row['num_media']]
|
results[compartment] = [row['num_media']]
|
||||||
|
|
||||||
q = Toutiao.objects.exclude(organization__cities='').values('organization__cities').order_by(
|
q = Toutiao.objects.exclude(organization__cities='', status=0).values('organization__cities').order_by(
|
||||||
'organization__cities').annotate(num_media=Count('organization__cities'))
|
'organization__cities').annotate(num_media=Count('organization__cities'))
|
||||||
for row in q:
|
for row in q:
|
||||||
code = row['organization__cities']
|
code = row['organization__cities']
|
||||||
|
if not code:
|
||||||
|
continue
|
||||||
compartment = COMPARTMENTS[code]
|
compartment = COMPARTMENTS[code]
|
||||||
if compartment in results:
|
if compartment in results:
|
||||||
nums = results[compartment]
|
nums = results[compartment]
|
||||||
|
@ -74,10 +80,12 @@ def monitor_statistics(request):
|
||||||
else:
|
else:
|
||||||
results[compartment] = [row['num_media']]
|
results[compartment] = [row['num_media']]
|
||||||
|
|
||||||
q = Douyin.objects.exclude(organization__cities='').values('organization__cities').order_by(
|
q = Douyin.objects.exclude(organization__cities='', status=0).values('organization__cities').order_by(
|
||||||
'organization__cities').annotate(num_media=Count('organization__cities'))
|
'organization__cities').annotate(num_media=Count('organization__cities'))
|
||||||
for row in q:
|
for row in q:
|
||||||
code = row['organization__cities']
|
code = row['organization__cities']
|
||||||
|
if not code:
|
||||||
|
continue
|
||||||
compartment = COMPARTMENTS[code]
|
compartment = COMPARTMENTS[code]
|
||||||
if compartment in results:
|
if compartment in results:
|
||||||
nums = results[compartment]
|
nums = results[compartment]
|
||||||
|
@ -85,17 +93,18 @@ def monitor_statistics(request):
|
||||||
else:
|
else:
|
||||||
results[compartment] = [row['num_media']]
|
results[compartment] = [row['num_media']]
|
||||||
|
|
||||||
q = Qita.objects.exclude(organization__cities='').values('organization__cities').order_by(
|
q = Qita.objects.exclude(organization__cities='', status=0).values('organization__cities').order_by(
|
||||||
'organization__cities').annotate(num_media=Count('organization__cities'))
|
'organization__cities').annotate(num_media=Count('organization__cities'))
|
||||||
for row in q:
|
for row in q:
|
||||||
code = row['organization__cities']
|
code = row['organization__cities']
|
||||||
|
if not code:
|
||||||
|
continue
|
||||||
compartment = COMPARTMENTS[code]
|
compartment = COMPARTMENTS[code]
|
||||||
if compartment in results:
|
if compartment in results:
|
||||||
nums = results[compartment]
|
nums = results[compartment]
|
||||||
nums.append(row['num_media'])
|
nums.append(row['num_media'])
|
||||||
else:
|
else:
|
||||||
results[compartment] = [row['num_media']]
|
results[compartment] = [row['num_media']]
|
||||||
|
|
||||||
|
|
||||||
chart2_data = []
|
chart2_data = []
|
||||||
for k in results:
|
for k in results:
|
||||||
|
|
Loading…
Reference in New Issue