[views] Move elaborate charts to the charts page

This commit is contained in:
2024-07-23 16:24:59 -04:00
parent dcd7196010
commit 74c32bc4d5
3 changed files with 35 additions and 8 deletions

View File

@ -664,6 +664,33 @@ class ChartRecordView(TemplateView):
),
"all": live_charts(**track_params, limit=limit),
}
limit = 14
artist = {"user": user, "media_type": "Artist", "limit": limit}
# This is weird. They don't display properly as QuerySets, so we cast to lists
context_data["chart_keys"] = {
"today": "Today",
"last7": "Last 7 days",
"last30": "Last 30 days",
"year": "This year",
"all": "All time",
}
context_data["current_artist_charts"] = {
"today": list(live_charts(**artist, chart_period="today")),
"last7": list(live_charts(**artist, chart_period="last7")),
"last30": list(live_charts(**artist, chart_period="last30")),
"year": list(live_charts(**artist, chart_period="year")),
"all": list(live_charts(**artist)),
}
track = {"user": user, "media_type": "Track", "limit": limit}
context_data["current_track_charts"] = {
"today": list(live_charts(**track, chart_period="today")),
"last7": list(live_charts(**track, chart_period="last7")),
"last30": list(live_charts(**track, chart_period="last30")),
"year": list(live_charts(**track, chart_period="year")),
"all": list(live_charts(**track)),
}
return context_data
# Date provided, lookup past charts, returning nothing if it's now or in the future.

View File

@ -3,6 +3,11 @@
{% block title %}{{name}}{% endblock %}
{% block lists %}
<div "calss="row>
{% include "scrobbles/_top_charts.html" %}
</div>
<div class="row">
{% if artist_charts %}
<div class="col-md">

View File

@ -82,19 +82,14 @@
{% if not user.is_authenticated %}
<p>Today <b>{{counts.today}}</b> | This Week <b>{{counts.week}}</b> | This Month <b>{{counts.month}}</b> | This Year <b>{{counts.year}}</b> | All Time <b>{{counts.alltime}}</b></p>
<canvas class="my-4 w-100" id="myChart" width="900" height="300"></canvas>
{% endif %}
{% else %}
<div class="container">
{% if user.is_authenticated %}
<div class="row">
{% include "scrobbles/_top_charts.html" %}
</div>
<div class="row">
{% include "scrobbles/_last_scrobbles.html" %}
</div>
{% endif %}
</div>
{% endif %}
</main>
<div class="modal fade" id="importModal" tabindex="-1" role="dialog" aria-labelledby="importModalLabel"