diff --git a/src/app/views/albums.zig b/src/app/views/albums.zig index 0805e67..94739ae 100644 --- a/src/app/views/albums.zig +++ b/src/app/views/albums.zig @@ -5,7 +5,8 @@ const jetquery = @import("jetzig").jetquery; pub fn index(request: *jetzig.Request) !jetzig.View { var root = try request.data(.object); var albums_view = try root.put("albums", .array); - const query = jetzig.database.Query(.Album).select(.{}) + const query = jetzig.database.Query(.Album) + .select(.{ .id, .name }) .include(.albumartists, .{ .select = .{.artist_id} }) .orderBy(.{ .name = .asc }); const albums = try request.repo.all(query); @@ -16,7 +17,7 @@ pub fn index(request: *jetzig.Request) !jetzig.View { var artist_infos = try album_view.put("artist_info", .array); for (album.albumartists) |artist| { var artist_info = try artist_infos.append(.object); - const artist_data = try jetzig.database.Query(.Artist).where(.{ .id = artist.artist_id }).all(request.repo); + const artist_data = try jetzig.database.Query(.Artist).select(.{ .id, .name }).where(.{ .id = artist.artist_id }).all(request.repo); for (artist_data) |ad| { try artist_info.put("name", ad.name); try artist_info.put("id", ad.id); @@ -35,7 +36,11 @@ pub fn get(id: []const u8, request: *jetzig.Request) !jetzig.View { var root = try request.data(.object); try root.put("album", album.?.name); var songs_view = try root.put("songs", .array); - const query = jetzig.database.Query(.Albumsong).include(.song, .{ .select = .{ .name, .id } }).join(.inner, .album).where(.{ .album = .{ .id = id } }); + const query = jetzig.database.Query(.Albumsong) + .select(.{.id}) + .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); diff --git a/src/app/views/artists.zig b/src/app/views/artists.zig index bb0db87..f03da7e 100644 --- a/src/app/views/artists.zig +++ b/src/app/views/artists.zig @@ -5,7 +5,9 @@ const jetquery = @import("jetzig").jetquery; pub fn index(request: *jetzig.Request) !jetzig.View { var root = try request.data(.object); var artists_view = try root.put("artists", .array); - const query = jetzig.database.Query(.Artist).select(.{}).orderBy(.{ .name = .asc }); + const query = jetzig.database.Query(.Artist) + .select(.{ .id, .name }) + .orderBy(.{ .name = .asc }); const artists = try request.repo.all(query); for (artists) |artist| { const scrobbles = try jetzig.database.Query(.Scrobbleartist).where(.{ .artist_id = artist.id }).count().execute(request.repo); @@ -26,6 +28,7 @@ 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) + .select(.{.id}) .include(.album, .{ .select = .{ .name, .id } }) .join(.inner, .artist) .where(.{ .artist = .{ .id = id } }); diff --git a/src/app/views/scrobbles.zig b/src/app/views/scrobbles.zig index 0fff9c3..f222b37 100644 --- a/src/app/views/scrobbles.zig +++ b/src/app/views/scrobbles.zig @@ -4,7 +4,7 @@ const jetzig = @import("jetzig"); pub fn index(request: *jetzig.Request) !jetzig.View { var root = try request.data(.object); var scrobbles_view = try root.put("scrobbles", .array); - const query = jetzig.database.Query(.Scrobble).select(.{}) + const query = jetzig.database.Query(.Scrobble).select(.{.date}) .include(.song, .{ .select = .{ .id, .name } }) .include(.album, .{ .select = .{ .id, .name } }) .include(.scrobbleartists, .{ .select = .{.artist_id} }) diff --git a/src/app/views/songs.zig b/src/app/views/songs.zig index 1da1d88..4b1301a 100644 --- a/src/app/views/songs.zig +++ b/src/app/views/songs.zig @@ -4,7 +4,10 @@ const jetzig = @import("jetzig"); pub fn index(request: *jetzig.Request) !jetzig.View { var root = try request.data(.object); var songs_view = try root.put("songs", .array); - const query = jetzig.database.Query(.Song).select(.{}).orderBy(.{ .name = .asc }); + const query = jetzig.database.Query(.Song) + .select(.{ .id, .name }) + .include(.songartists, .{ .select = .{.artist_id} }) + .orderBy(.{ .name = .asc }); const songs = try request.repo.all(query); for (songs) |song| { const scrobbles = try jetzig.database.Query(.Scrobble).where(.{ .song_id = song.id }).count().execute(request.repo);