mirror of
https://gitlab.science.ru.nl/technicie/MarietjeDjango.git
synced 2025-12-09 18:52:23 +01:00
changed Most played uploads to exclude your requests, and some small fixes
This commit is contained in:
@ -8,17 +8,22 @@
|
||||
<h1>User Statistics</h1>
|
||||
|
||||
<div class="row">
|
||||
{% if not stats %}
|
||||
<div class="alert alert-danger">
|
||||
<strong>Stats unavailable :(</strong>
|
||||
</div>
|
||||
{% else %}
|
||||
{% if current_age_text %}
|
||||
<div class="alert alert-info">
|
||||
<strong>{{ current_age_text }}</strong>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<h4>Total uploads: {{ stats.total_uploads }}</h4>
|
||||
<h4>Total requests: {{ stats.total_requests }}</h4>
|
||||
<h4>Unique requests: {{ stats.unique_requests }} ({% widthratio stats.unique_requests stats.total_requests 100 %}%)</h4>
|
||||
<h4>Total requested uploads: {{stats.total_played_uploads}}</h4>
|
||||
<div class="col-md-6">
|
||||
<h2>Most played songs</h2>
|
||||
<h4>Total: {{ stats.total_requests }}</h4>
|
||||
<h4>Top {{ stats.stats_top_count }}:</h4>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
@ -45,7 +50,8 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<h2>Most played uploads</h2>
|
||||
<h2>Uploads requested by others</h2>
|
||||
<h4>Total: {{stats.total_played_uploads}}</h4>
|
||||
<h4>Top {{ stats.stats_top_count }}:</h4>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
@ -87,7 +93,7 @@
|
||||
<tr>
|
||||
<th>{{ forloop.counter }}</th>
|
||||
<td>{{ stat.song__user__name }}</td>
|
||||
<td>{{ stat.total }} ({% widthratio stat.total total_requests 100 %}%)</td>
|
||||
<td>{{ stat.total }} ({% widthratio stat.total stats.total_requests 100 %}%)</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
@ -95,5 +101,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
@ -60,7 +60,7 @@ def compute_stats():
|
||||
'user__id', 'user__name').annotate(
|
||||
total_requests=Count('id', distinct=True),
|
||||
unique_requests=Count('song__id', distinct=True)).order_by(
|
||||
'-total_requests')[:settings.STATS_TOP_COUNT]
|
||||
'-unique_requests')[:settings.STATS_TOP_COUNT]
|
||||
|
||||
total_unique_requests = PlaylistSong.objects.filter(state=2).exclude(
|
||||
Q(user_id=None)
|
||||
@ -145,16 +145,15 @@ def user_stats(request):
|
||||
'-total')[:settings.STATS_TOP_COUNT]
|
||||
|
||||
most_played_uploads = PlaylistSong.objects.filter(
|
||||
state=2, song_id__in=Song.objects.filter(user__id=request)).exclude(
|
||||
Q(user_id=None)
|
||||
| Q(user_id__in=settings.STATS_REQUEST_IGNORE_USER_IDS)).values(
|
||||
'pk').values(
|
||||
state=2, song_id__in=Song.objects.filter(user__id=request)).exclude(Q(user__id=None)|Q(user__id=request)).values(
|
||||
'song__artist',
|
||||
'song__title').annotate(total=Count('id')).order_by(
|
||||
'-total', 'song__artist',
|
||||
'song__title')[:settings.STATS_TOP_COUNT]
|
||||
|
||||
total_played_uploads = most_played_uploads.aggregate(newtotal=Sum('total'))
|
||||
most_played = list(most_played_uploads)
|
||||
total_played_uploads = 0
|
||||
for x in most_played:
|
||||
total_played_uploads += x['total']
|
||||
|
||||
return {
|
||||
'last_updated': last_updated,
|
||||
@ -165,6 +164,6 @@ def user_stats(request):
|
||||
'most_played_uploaders': list(most_played_uploaders),
|
||||
'most_played_uploads': list(most_played_uploads),
|
||||
'stats_top_count': settings.STATS_TOP_COUNT,
|
||||
'total_played_uploads': total_played_uploads['newtotal'],
|
||||
'total_played_uploads': total_played_uploads,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user