From 1184677fab10b361c87f7c6a6679f7b32858b7da Mon Sep 17 00:00:00 2001 From: mitteneer Date: Tue, 4 Mar 2025 15:36:34 -0500 Subject: [PATCH] Include number of scrobbles in artist view --- src/app/views/artists.zig | 2 ++ src/app/views/artists/get.zmpl | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/app/views/artists.zig b/src/app/views/artists.zig index a1e464a..646ccc8 100644 --- a/src/app/views/artists.zig +++ b/src/app/views/artists.zig @@ -26,9 +26,11 @@ pub fn get(id: []const u8, request: *jetzig.Request) !jetzig.View { const query = jetzig.database.Query(.Albumartist).include(.album, .{ .select = .{ .name, .id } }).join(.inner, .artist).where(.{ .artist = .{ .id = id } }); const albums = try request.repo.all(query); for (albums) |album| { + const scrobbles = try jetzig.database.Query(.Scrobble).where(.{ .album_id = album.album.id }).count().execute(request.repo); var album_view = try albums_view.append(.object); try album_view.put("name", album.album.name); try album_view.put("url", album.album.id); + try album_view.put("scrobbles", scrobbles); //std.log.debug("{s}", .{album.album.name}); } return request.render(.ok); diff --git a/src/app/views/artists/get.zmpl b/src/app/views/artists/get.zmpl index c81d57d..6e9e1bf 100644 --- a/src/app/views/artists/get.zmpl +++ b/src/app/views/artists/get.zmpl @@ -8,10 +8,11 @@

{{.artist}}

- + @for (.albums) |album| { + }
NameNameScrobbles
{{album.name}}{{album.scrobbles}}