Include number of scrobbles in artist view

This commit is contained in:
mitteneer 2025-03-04 15:36:34 -05:00
parent 69d126bd90
commit 1184677fab
2 changed files with 4 additions and 1 deletions

View file

@ -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);

View file

@ -8,10 +8,11 @@
<h1>{{.artist}}</h1>
<table>
<tr>
<th>Name</th>
<th>Name</th><th>Scrobbles</th>
@for (.albums) |album| {
<tr>
<td class=cell><a href="/albums/{{album.url}}">{{album.name}}</a></td>
<td calss=cell>{{album.scrobbles}}</td>
</tr>
}
</table>