diff --git a/PROJECT.org b/PROJECT.org index f0cf3b8..1421346 100644 --- a/PROJECT.org +++ b/PROJECT.org @@ -88,7 +88,7 @@ fetching and simple saving. *** Metadata sources **** Scraper -* Backlog [0/23] :vrobbler:project:personal: +* Backlog [1/24] :vrobbler:project:personal: ** TODO [#C] After transition to linux add curl_cffi as webpage scrapper again :webpages:metadata: ** TODO [#C] Create small utility to clean up tracks scrobbled with wonky playback times :bug:music:scrobbles: :PROPERTIES: @@ -605,6 +605,10 @@ independent of the email flow it was originally creatdd for ** TODO [#B] Is there way to create unique slugs for media instances :media_types: +** DONE [#B] Clean up trend templates :trends:templates: +:PROPERTIES: +:ID: 83237e2c-857b-47c9-c86c-32a5e3f1359d +:END: * Version 58.7 [2/2] ** DONE [#B] Split up chart page between tables and maloja :charts:templates: :PROPERTIES: diff --git a/vrobbler/apps/charts/views.py b/vrobbler/apps/charts/views.py index 9a88541..beb1831 100644 --- a/vrobbler/apps/charts/views.py +++ b/vrobbler/apps/charts/views.py @@ -447,9 +447,13 @@ class MalojaChartsView(ChartRecordView): context = super(ChartRecordView, self).get_context_data(**kwargs) user = self.request.user + if not user.is_authenticated: + context["maloja_charts"] = {} + context["chart_keys"] = {} + return context + now = timezone.now() - if user.is_authenticated: - now = now_user_timezone(user.profile) + now = now_user_timezone(user.profile) today = now.date() context["chart_keys"] = { diff --git a/vrobbler/apps/trends/templates/trends/_activity_distribution.html b/vrobbler/apps/trends/templates/trends/_activity_distribution.html index aa480d3..c086b60 100644 --- a/vrobbler/apps/trends/templates/trends/_activity_distribution.html +++ b/vrobbler/apps/trends/templates/trends/_activity_distribution.html @@ -1,45 +1,78 @@
{% if data.distribution %} + {{ data.distribution|json_script:"activity-distribution-data" }}

Total scrobbles{% if current_period_label %} ({{ current_period_label }}){% endif %}: {{ data.total_count }}

-
- - - - - - - - - - - - {% with max=data.distribution.0.count %} - {% for entry in data.distribution %} - - - - - - - - {% endfor %} - {% endwith %} - -
Media TypeTotalCompleted%Distribution
{{ entry.media_type }}{{ entry.count }}{{ entry.completed }}{{ entry.pct }}% - {% if max > 0 %} -
-
-
-
- {% endif %} -
-
+ + {% else %}

No activity data found.

{% endif %} diff --git a/vrobbler/apps/trends/templates/trends/_mood_distribution.html b/vrobbler/apps/trends/templates/trends/_mood_distribution.html index 78438cc..3231166 100644 --- a/vrobbler/apps/trends/templates/trends/_mood_distribution.html +++ b/vrobbler/apps/trends/templates/trends/_mood_distribution.html @@ -1,43 +1,74 @@
{% if data.moods %} + {{ data.moods|json_script:"mood-distribution-data" }}

Total mood check-ins{% if current_period_label %} ({{ current_period_label }}){% endif %}: {{ data.total }} · Positive: {{ data.positive_count }} · Negative: {{ data.negative_count }}

-
- - - - - - - - - - {% with max=data.moods.0.count %} - {% for entry in data.moods %} - - - - - - {% endfor %} - {% endwith %} - -
MoodCountDistribution
{{ entry.mood }}{{ entry.count }} - {% if max > 0 %} -
-
-
-
- {% endif %} -
-
+ + {% else %}

No mood distribution data found.

{% endif %} diff --git a/vrobbler/apps/trends/templates/trends/_mood_trajectory.html b/vrobbler/apps/trends/templates/trends/_mood_trajectory.html index 78ff5dc..ecbe15e 100644 --- a/vrobbler/apps/trends/templates/trends/_mood_trajectory.html +++ b/vrobbler/apps/trends/templates/trends/_mood_trajectory.html @@ -1,37 +1,105 @@
{% if data.trajectory %} -
- - - - - - - - - - - {% for entry in data.trajectory %} - - - - - - - {% endfor %} - -
DateAvg QualityCheck-insMood Bar
{{ entry.date }}{{ entry.avg_quality }}{{ entry.count }} -
-
-
-
-
+ {{ data.trajectory|json_script:"mood-trajectory-data" }} +
+ +
+ ← Earlier + Later → +
+ {% else %}

No mood check-in data found.

{% endif %} diff --git a/vrobbler/apps/trends/templates/trends/_peak_hours.html b/vrobbler/apps/trends/templates/trends/_peak_hours.html index 5385e96..eb4ea22 100644 --- a/vrobbler/apps/trends/templates/trends/_peak_hours.html +++ b/vrobbler/apps/trends/templates/trends/_peak_hours.html @@ -1,50 +1,90 @@
{% if data.hours %} -
- - - - - - - - - - {% with total=data.hours|dictsortreversed:"count"|first %} - {% with max_count=total.count %} - {% for entry in data.hours %} - - - - - - {% endfor %} - {% endwith %} - {% endwith %} - -
HourScrobblesDistribution
- {% if entry.hour == 0 %} - 12 AM - {% elif entry.hour < 12 %} - {{ entry.hour }} AM - {% elif entry.hour == 12 %} - 12 PM - {% else %} - {{ entry.hour|add:"-12" }} PM - {% endif %} - {{ entry.count }} - {% if max_count > 0 %} -
-
-
-
- {% endif %} -
+ {{ data.hours|json_script:"peak-hours-data" }} +
+
+ +
+
+ + + + + + + + + + {% for entry in data.hours %} + + + + + + {% endfor %} + +
HourScrobbles
+ + + {% if entry.hour == 0 %} + 12 AM + {% elif entry.hour < 12 %} + {{ entry.hour }} AM + {% elif entry.hour == 12 %} + 12 PM + {% else %} + {{ entry.hour|add:"-12" }} PM + {% endif %} + {{ entry.count }}
+
+ {% else %}

No activity data found.

{% endif %} diff --git a/vrobbler/apps/trends/templates/trends/_time_of_day_categories.html b/vrobbler/apps/trends/templates/trends/_time_of_day_categories.html index a80a5de..31f0e25 100644 --- a/vrobbler/apps/trends/templates/trends/_time_of_day_categories.html +++ b/vrobbler/apps/trends/templates/trends/_time_of_day_categories.html @@ -1,31 +1,45 @@
{% if data.total and data.total > 0 %} -
Overall
-
- - - - - - - - - - {% for slug, info in data.categories.items %} - - - - - - {% endfor %} - - - - - - -
CategoryScrobbles%
{{ info.label }}{{ info.count }}{{ info.pct }}%
Total{{ data.total }}
+
+ {% for slug, info in data.categories.items %} + {% if forloop.first %} +
+
+ {% if slug == "early_bird" %} +
🌅
+ {% elif slug == "day_jay" %} +
☀️
+ {% else %} +
🌙
+ {% endif %} +

{{ info.label }}

+
{{ info.pct }}%
+
{{ info.count }} scrobbles
+
+
+ {% else %} +
+
+
+ {% if slug == "early_bird" %} + 🌅 + {% elif slug == "day_jay" %} + ☀️ + {% else %} + 🌙 + {% endif %} +
{{ info.label }}
+
+
+ {{ info.pct }}% +
{{ info.count }} scrobbles +
+
+
+ {% endif %} + {% endfor %} +
Total: {{ data.total }} scrobbles across Books, Trails, Birding Locations, and Board Games
By Media Type
diff --git a/vrobbler/apps/trends/templates/trends/_trending_up.html b/vrobbler/apps/trends/templates/trends/_trending_up.html index c849e24..f9b3a77 100644 --- a/vrobbler/apps/trends/templates/trends/_trending_up.html +++ b/vrobbler/apps/trends/templates/trends/_trending_up.html @@ -1,38 +1,27 @@ -
-
- {% if data %} -
- - - - - - - - - - - {% for mt, info in data.items %} - - - - - - - {% endfor %} - -
Media TypeRecent ({{ current_period_label }})Previous ({{ current_period_label }})Change
{{ mt }}{{ info.recent }}{{ info.previous }} - {% if info.change_pct > 0 %} - +{{ info.change_pct }}% - {% elif info.change_pct < 0 %} - {{ info.change_pct }}% - {% else %} - 0% - {% endif %} -
+
+ {% if data %} + {% for mt, info in data.items %} +
+
+
+ {% if info.change_pct > 0 %} +
+
+{{ info.change_pct }}%
+ {% elif info.change_pct < 0 %} +
+
{{ info.change_pct }}%
+ {% else %} +
+
0%
+ {% endif %} +
{{ mt }}
+
+
- {% else %} -

No trending data found.

- {% endif %} -
+ {% endfor %} + {% else %} +
+

No trending data found.

+
+ {% endif %}
diff --git a/vrobbler/apps/trends/trends/time_of_day.py b/vrobbler/apps/trends/trends/time_of_day.py index 9ac4b21..9fcd5e6 100644 --- a/vrobbler/apps/trends/trends/time_of_day.py +++ b/vrobbler/apps/trends/trends/time_of_day.py @@ -59,18 +59,21 @@ def compute_time_of_day_categories(user, period="last_30"): if slug: cat_counts[slug] += count mt_total += count - by_media_type[mt] = { - "total": mt_total, - "categories": {}, - } + mt_categories = {} for slug in CATEGORIES: c = cat_counts[slug] - by_media_type[mt]["categories"][slug] = { + mt_categories[slug] = { "count": c, "pct": round((c / mt_total * 100), 1) if mt_total else 0, "label": CATEGORIES[slug]["label"], } grand_totals[slug] += c + by_media_type[mt] = { + "total": mt_total, + "categories": dict( + sorted(mt_categories.items(), key=lambda x: x[1]["count"], reverse=True) + ), + } grand_total += mt_total categories = {} @@ -81,6 +84,9 @@ def compute_time_of_day_categories(user, period="last_30"): "pct": round((c / grand_total * 100), 1) if grand_total else 0, "label": CATEGORIES[slug]["label"], } + categories = dict( + sorted(categories.items(), key=lambda x: x[1]["count"], reverse=True) + ) return { "categories": categories,