Work on artists view
This commit is contained in:
parent
1184677fab
commit
9e2b676aef
3 changed files with 13 additions and 6 deletions
|
|
@ -24,13 +24,21 @@ pub fn get(id: []const u8, request: *jetzig.Request) !jetzig.View {
|
|||
try root.put("artist", artist.?.name);
|
||||
var albums_view = try root.put("albums", .array);
|
||||
const query = jetzig.database.Query(.Albumartist).include(.album, .{ .select = .{ .name, .id } }).join(.inner, .artist).where(.{ .artist = .{ .id = id } });
|
||||
|
||||
//const query = jetzig.database.Query(.Albumartist)
|
||||
// .select(.{ .artist_id, jetquery.sql.count(.album_id) })
|
||||
// .groupBy(.{.artist_id})
|
||||
// .orderBy(.count__album_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);
|
||||
//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);
|
||||
//try album_view.put("name", album.count__album_id);
|
||||
//try album_view.put("url", album.count__album_id);
|
||||
try album_view.put("scrobbles", 6);
|
||||
//std.log.debug("{s}", .{album.album.name});
|
||||
}
|
||||
return request.render(.ok);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue