diff --git a/.gitignore b/.gitignore
index ea7b5c1..70b0239 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,4 @@ static/
src/app/database/data.db-journal
src/app/database/old_migrations/
src/lib
+src/app/scripts/
\ No newline at end of file
diff --git a/src/app/views/artists/get.zmpl b/src/app/views/artists/get.zmpl
index 931fe9c..9913061 100644
--- a/src/app/views/artists/get.zmpl
+++ b/src/app/views/artists/get.zmpl
@@ -1,20 +1,32 @@
+
@partial partials/header
{{.artist}}
-
+
+
| Name | Scrobbles |
+
+
+
@for (.albums) |album| {
| {{album.name}} |
{{album.scrobbles}} |
}
+
+
+
\ No newline at end of file
diff --git a/src/app/views/artists/index.zmpl b/src/app/views/artists/index.zmpl
index a122138..6854e07 100644
--- a/src/app/views/artists/index.zmpl
+++ b/src/app/views/artists/index.zmpl
@@ -1,20 +1,34 @@
-
+
@partial partials/header
- Artists
-
+Artists
+
+
| Name |
+Scrobbles |
+
+
+
@for (.artists) |artist| {
| {{artist.name}} |
{{artist.scrobbles}} |
}
+
+
+
\ No newline at end of file
diff --git a/src/app/views/scrobbles.zig b/src/app/views/scrobbles.zig
index 5ce68e9..7bd4f19 100644
--- a/src/app/views/scrobbles.zig
+++ b/src/app/views/scrobbles.zig
@@ -1,8 +1,36 @@
const std = @import("std");
const jetzig = @import("jetzig");
-pub fn index(request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
- _ = data;
+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(.{})
+ .include(.song, .{ .select = .{ .id, .name } })
+ .include(.album, .{ .select = .{ .id, .name } })
+ .include(.scrobbleartists, .{ .select = .{.artist_id} })
+ .orderBy(.{ .date = .desc });
+ const scrobbles = try request.repo.all(query);
+ for (scrobbles) |scrobble| {
+ var scrobble_view = try scrobbles_view.append(.object);
+
+ var artist_infos = try scrobble_view.put("artist_info", .array);
+ for (scrobble.scrobbleartists) |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);
+ for (artist_data) |ad| {
+ try artist_info.put("name", ad.name);
+ try artist_info.put("id", ad.id);
+ }
+ }
+
+ try scrobble_view.put("song_name", scrobble.song.name);
+ try scrobble_view.put("song_id", scrobble.song.id);
+ try scrobble_view.put("artist_name", "placeholder");
+ try scrobble_view.put("artist_id", "placeholder");
+ try scrobble_view.put("album_name", scrobble.album.name);
+ try scrobble_view.put("album_id", scrobble.album.id);
+ try scrobble_view.put("date", scrobble.date);
+ }
return request.render(.ok);
}
diff --git a/src/app/views/scrobbles/index.zmpl b/src/app/views/scrobbles/index.zmpl
index 48b753a..377f50f 100644
--- a/src/app/views/scrobbles/index.zmpl
+++ b/src/app/views/scrobbles/index.zmpl
@@ -1,16 +1,42 @@
-
+
+
@partial partials/header
-
- Look for an artist
-
-
+Scrobbles
+
+
+
-
+