Add scrobble count to each artist/album/song view
This commit is contained in:
parent
7ee3abe857
commit
4adbd59e12
7 changed files with 32 additions and 16 deletions
|
|
@ -23,9 +23,11 @@ pub fn get(id: []const u8, request: *jetzig.Request) !jetzig.View {
|
|||
const query = jetzig.database.Query(.Albumsong).include(.song, .{ .select = .{ .name, .id } }).join(.inner, .album).where(.{ .album = .{ .id = id } });
|
||||
const songs = try request.repo.all(query);
|
||||
for (songs) |song| {
|
||||
const scrobbles = try jetzig.database.Query(.Scrobble).where(.{ .song_id = song.song.id }).count().execute(request.repo);
|
||||
var song_view = try songs_view.append(.object);
|
||||
try song_view.put("name", song.song.name);
|
||||
try song_view.put("url", song.song.id);
|
||||
try song_view.put("scrobbles", scrobbles);
|
||||
}
|
||||
return request.render(.ok);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue