From 09f542e26e84b6a1e2dd9e5abed7a20d5547a7be Mon Sep 17 00:00:00 2001 From: mitteneer Date: Sat, 24 May 2025 13:58:31 -0400 Subject: [PATCH] Add timescale partial Bad name, idk what else to call it --- src/app/views/albums/get.zmpl | 4 ++++ src/app/views/artists/get.zmpl | 5 +++-- src/app/views/partials/_firstlast_listens.zmpl | 10 +++++++--- src/app/views/partials/_timescale.zmpl | 18 ++++++++++++++++++ 4 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 src/app/views/partials/_timescale.zmpl diff --git a/src/app/views/albums/get.zmpl b/src/app/views/albums/get.zmpl index 3a1641b..1024ec5 100644 --- a/src/app/views/albums/get.zmpl +++ b/src/app/views/albums/get.zmpl @@ -10,6 +10,10 @@ @partial partials/header

{{.album}}

+@partial partials/firstlast_listens(scrobbles: .album.scrobbles, rank: .album.rank, firstlast: .firstlast) +

Yearly Performance

+@partial partials/timescale(range: .yearly) +

Songs

@partial partials/newtable(T: ColumnChoices, table_data: .songs, columns: columns) \ No newline at end of file diff --git a/src/app/views/artists/get.zmpl b/src/app/views/artists/get.zmpl index 48c1c25..69bd661 100644 --- a/src/app/views/artists/get.zmpl +++ b/src/app/views/artists/get.zmpl @@ -10,8 +10,9 @@ @partial partials/header

{{.artist.name}}

-@partial partials/firstlast_listens(scrobbles: .artist.scrobbles, rank: .artist.rank, last_song: .last, first_song: .first) - +@partial partials/firstlast_listens(scrobbles: .artist.scrobbles, rank: .artist.rank, firstlast: .firstlast) +

Yearly Performance

+@partial partials/timescale(range: .yearly)

Albums

@partial partials/newtable(T: ColumnChoices, table_data: .albums, columns: columns) diff --git a/src/app/views/partials/_firstlast_listens.zmpl b/src/app/views/partials/_firstlast_listens.zmpl index 322a0e8..ed74361 100644 --- a/src/app/views/partials/_firstlast_listens.zmpl +++ b/src/app/views/partials/_firstlast_listens.zmpl @@ -1,9 +1,13 @@ -@args scrobbles: i64, rank: []const u8, last_song: *ZmplValue, first_song: *ZmplValue +@args scrobbles: i64, rank: []const u8, firstlast: *ZmplValue + +@zig { + const songs = firstlast.items(.array); +}
{{scrobbles}} scrobbles ({{rank}} place)
-First listen: {{first_song.name}} ({{first_song.date}}) +First listen: {{songs[0].name}} ({{songs[0].date}})
-Most recent listen: {{last_song.name}} ({{last_song.date}}) +Most recent listen: {{songs[1].name}} ({{songs[1].date}})
\ No newline at end of file diff --git a/src/app/views/partials/_timescale.zmpl b/src/app/views/partials/_timescale.zmpl new file mode 100644 index 0000000..fdec7a1 --- /dev/null +++ b/src/app/views/partials/_timescale.zmpl @@ -0,0 +1,18 @@ +@args range: *ZmplValue + + + + + + + + + +@for (range) |itm| { + + + + +} + +
YearScrobbles
{{itm.year}}:{{itm.scrobbles}}
\ No newline at end of file