From a598562e24d8700c0fb599fd564c5c91030632cb Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Sun, 19 Jul 2026 15:43:08 -0400 Subject: [PATCH] feat(trends): add 7-day period option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add 'last_7' (Last 7 days) as a selectable period for all trends. Changes are minimal since the period system is driven by PERIOD_CHOICES and PERIOD_DAYS dicts — the rest of the infrastructure (views, templates, Celery tasks, management commands) picks it up automatically. - Add ('last_7', 'Last 7 days') to PERIOD_CHOICES in models.py - Add 'last_7': 7 to PERIOD_DAYS in utils.py - Migration 0004_alter_trendresult_period_add_last_7 --- PROJECT.org | 6 ++++- ...004_alter_trendresult_period_add_last_7.py | 27 +++++++++++++++++++ vrobbler/apps/trends/models.py | 1 + vrobbler/apps/trends/utils.py | 1 + 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 vrobbler/apps/trends/migrations/0004_alter_trendresult_period_add_last_7.py diff --git a/PROJECT.org b/PROJECT.org index 9ccade4..f2b9700 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/25] :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: @@ -601,6 +601,10 @@ The Edit log form should have from top to bottom: *** Description ** TODO [#A] Add trends tests for concurrent trends :trends:tests:concurrent: +** DONE [#B] Add 7-day period for trends :trends: +:PROPERTIES: +:ID: 95731744-b0ec-175e-88dc-822cf9110292 +:END: * Version 61.3 [1/1] ** DONE [#A] Add trends tests and fix fasting :trends:tests:fasting: :PROPERTIES: diff --git a/vrobbler/apps/trends/migrations/0004_alter_trendresult_period_add_last_7.py b/vrobbler/apps/trends/migrations/0004_alter_trendresult_period_add_last_7.py new file mode 100644 index 0000000..54197d4 --- /dev/null +++ b/vrobbler/apps/trends/migrations/0004_alter_trendresult_period_add_last_7.py @@ -0,0 +1,27 @@ +# Generated by Django 4.2.29 on 2026-07-19 19:39 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("trends", "0003_alter_trendresult_period"), + ] + + operations = [ + migrations.AlterField( + model_name="trendresult", + name="period", + field=models.CharField( + choices=[ + ("last_7", "Last 7 days"), + ("last_30", "Last 30 days"), + ("last_90", "Last 90 days"), + ("last_year", "Last year"), + ], + default="last_30", + max_length=20, + ), + ), + ] diff --git a/vrobbler/apps/trends/models.py b/vrobbler/apps/trends/models.py index 551f0a1..e8c30cd 100644 --- a/vrobbler/apps/trends/models.py +++ b/vrobbler/apps/trends/models.py @@ -5,6 +5,7 @@ from django_extensions.db.models import TimeStampedModel User = get_user_model() PERIOD_CHOICES = [ + ("last_7", "Last 7 days"), ("last_30", "Last 30 days"), ("last_90", "Last 90 days"), ("last_year", "Last year"), diff --git a/vrobbler/apps/trends/utils.py b/vrobbler/apps/trends/utils.py index 31f1e12..f68d4ea 100644 --- a/vrobbler/apps/trends/utils.py +++ b/vrobbler/apps/trends/utils.py @@ -8,6 +8,7 @@ from trends.trends import TREND_REGISTRY logger = logging.getLogger(__name__) PERIOD_DAYS = { + "last_7": 7, "last_30": 30, "last_90": 90, "last_year": 365,