Skip to content
This repository has been archived by the owner on Jan 28, 2021. It is now read-only.

Commit

Permalink
Merge pull request #89 from uw-it-aca/hotfix/moar-stats
Browse files Browse the repository at this point in the history
Adding more info to the stats page
  • Loading branch information
vegitron committed Apr 19, 2017
2 parents 0d3c04d + 1fab1ca commit 4ab8b94
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
13 changes: 13 additions & 0 deletions sqlshare_rest/templates/admin/stats.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.bundle.min.js" integrity="sha256-+q+dGCSrVbejd3MDuzJHKsk2eXd4sF5XYEMfPZsOnYE=" crossorigin="anonymous"></script>

<div class="container">

<h3>Top users:</h3>
<h4>By Dataset</h4>
{% for user in top_dataset_users %}
{{ user.username }}: {{ user.num_datasets }} datasets <br />
{% endfor %}

<h4>By Query</h4>
{% for user in top_query_users %}
{{ user.username }}: {{ user.num_queries }} queries. <br />
{% endfor %}


<h3>Users:</h3>
<canvas id="user_chart" width="400" height="150"></canvas>

Expand Down
10 changes: 10 additions & 0 deletions sqlshare_rest/views/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,16 @@ def stats(request):
'queries': u.num_queries,
})

top_datasets = User.objects.annotate(num_datasets=Count('dataset',
distinct=True))
top_datasets = top_datasets.order_by('-num_datasets')[:10]
context['top_dataset_users'] = top_datasets

top_queries = User.objects.annotate(num_queries=Count('query',
distinct=True))
top_queries = top_queries.order_by('-num_queries')[:10]
context['top_query_users'] = top_queries

public_count = 0
shared_count = 0
datasets = Dataset.objects.annotate(Count('datasetsharingemail',
Expand Down

0 comments on commit 4ab8b94

Please sign in to comment.