diff --git a/topics/urls.py b/topics/urls.py index 4f91162..7063692 100644 --- a/topics/urls.py +++ b/topics/urls.py @@ -10,5 +10,4 @@ urlpatterns = [ url(r'^view_log/(?P[\w_-]+)/$', views.topic_view_log, name = 'view_log'), url(r'^update_order/$', views.update_order, name = 'update_order'), url(r'^update_resource_order/$', views.update_resource_order, name = 'update_resource_order'), - url(r'^count_resources/$', views.getResourceCount, name='resource_count'), ] diff --git a/topics/views.py b/topics/views.py index 943c292..b11a215 100644 --- a/topics/views.py +++ b/topics/views.py @@ -276,27 +276,3 @@ def update_resource_order(request): return JsonResponse({'message': 'No data received'}) -def getResourceCount(request): - resources = Resource.objects.distinct() - - data = {} - for resource in resources: - key = resource.__dict__['_my_subclass'] - if key in data.keys(): - data[key] = data[key] + 1 - else: - data[key] = 1 - - data = [(key,value) for key,value in sorted(data.items(), key=operator.itemgetter(1), reverse=True)] - - others = data[4:] - total_others = 0 - for key,value in others: - total_others += value - - del data[4:] #remove from the 5th element - data.append(("others", total_others)) #so I have the sum of all other resources added up - real_data = [] - for key,value in data: - real_data.append((key,value)) - return JsonResponse(real_data, safe=False) -- libgit2 0.21.2