feat(trends): add 7-day period option

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
This commit is contained in:
2026-07-19 15:43:08 -04:00
parent bb63e529e7
commit a598562e24
4 changed files with 34 additions and 1 deletions

View File

@ -88,7 +88,7 @@ fetching and simple saving.
*** Metadata sources *** Metadata sources
**** Scraper **** 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] 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: ** TODO [#C] Create small utility to clean up tracks scrobbled with wonky playback times :bug:music:scrobbles:
:PROPERTIES: :PROPERTIES:
@ -601,6 +601,10 @@ The Edit log form should have from top to bottom:
*** Description *** Description
** TODO [#A] Add trends tests for concurrent trends :trends:tests:concurrent: ** 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] * Version 61.3 [1/1]
** DONE [#A] Add trends tests and fix fasting :trends:tests:fasting: ** DONE [#A] Add trends tests and fix fasting :trends:tests:fasting:
:PROPERTIES: :PROPERTIES:

View File

@ -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,
),
),
]

View File

@ -5,6 +5,7 @@ from django_extensions.db.models import TimeStampedModel
User = get_user_model() User = get_user_model()
PERIOD_CHOICES = [ PERIOD_CHOICES = [
("last_7", "Last 7 days"),
("last_30", "Last 30 days"), ("last_30", "Last 30 days"),
("last_90", "Last 90 days"), ("last_90", "Last 90 days"),
("last_year", "Last year"), ("last_year", "Last year"),

View File

@ -8,6 +8,7 @@ from trends.trends import TREND_REGISTRY
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
PERIOD_DAYS = { PERIOD_DAYS = {
"last_7": 7,
"last_30": 30, "last_30": 30,
"last_90": 90, "last_90": 90,
"last_year": 365, "last_year": 365,