diff --git a/src/app/views/groups/index.zmpl b/src/app/views/groups/index.zmpl index 1522924..76457d0 100644 --- a/src/app/views/groups/index.zmpl +++ b/src/app/views/groups/index.zmpl @@ -1,11 +1,3 @@ - - - - -@partial partials/header - -

Merge Songs

-
- -
-
\ No newline at end of file +
+ Content goes here +
diff --git a/src/app/views/songs.zig b/src/app/views/songs.zig index b634534..164f928 100644 --- a/src/app/views/songs.zig +++ b/src/app/views/songs.zig @@ -5,15 +5,7 @@ const queries = @import("../../queries.zig"); pub fn index(request: *jetzig.Request) !jetzig.View { var root = try request.data(.object); - const htmx_query = (try request.queryParams()).getT(.string, "s"); - - try root.put("htmx", htmx_query != null); - - const songs = if (htmx_query) |name| - try queries.entityQueryResult(request, queries.loadQuery(.song, .entities_by_name), .{name}) - else - try queries.entityQueryResult(request, queries.loadQuery(.song, .entities), .{}); - + const songs = try queries.entityQueryResult(request, queries.loadQuery(.song, .entities), .{}); try root.put("songs", songs); return request.render(.ok); diff --git a/src/app/views/songs/index.zmpl b/src/app/views/songs/index.zmpl index 862b753..6964630 100644 --- a/src/app/views/songs/index.zmpl +++ b/src/app/views/songs/index.zmpl @@ -1,6 +1,6 @@ @zig { const ColumnChoices = []const enum{song, album, artist, artistlist, scrobbles, date}; - const columns: ColumnChoices = &.{.song, .album, .artistlist, .scrobbles}; + const columns: ColumnChoices = &.{.song, .artistlist, .scrobbles}; } @@ -8,10 +8,8 @@ - @if (! $.htmx) @partial partials/header

Songs

- @end @partial partials/newtable(T: ColumnChoices, table_data: .songs, columns: columns) \ No newline at end of file diff --git a/src/queries.zig b/src/queries.zig index fcc5f07..ba2a734 100644 --- a/src/queries.zig +++ b/src/queries.zig @@ -49,7 +49,7 @@ pub fn entityQueryResult(request: *jetzig.Request, query: GeneratedQuery, args: } const EntityType = enum { scrobble, song, album, artist }; -const QueryTypeEnum = enum { firstlast, timescale, entities, get_songs, get_albums, get_scrobbles, appears, entity_info, datestreak, entities_by_name }; +const QueryTypeEnum = enum { firstlast, timescale, entities, get_songs, get_albums, get_scrobbles, appears, entity_info, datestreak }; const GeneratedQuery = struct { entity: EntityType, @@ -209,14 +209,13 @@ pub fn loadQuery(entity: EntityType, query_type: QueryTypeEnum) GeneratedQuery { \\ORDER BY scrobbles.datetime ASC , .song => - \\SELECT songs.name AS song_name, songs.id AS song_id, albums.name AS album_name, albums.id AS album_id, artists.name AS artist_name, artists.id AS artist_id, COUNT(scrobbles) AS scrobbles + \\SELECT songs.name AS song_name, songs.id AS song_id, artists.name AS artist_name, artists.id AS artist_id, COUNT(scrobbles) AS scrobbles \\FROM albumsongs \\INNER JOIN songs ON albumsongs.song_id = songs.id \\INNER JOIN scrobbles ON scrobbles.albumsong = albumsongs.id \\INNER JOIN albumsongsartists ON albumsongsartists.albumsong_id = albumsongs.id \\INNER JOIN artists ON artists.id = albumsongsartists.artist_id - \\INNER JOIN albums ON albums.id = albumsongs.album_id - \\GROUP BY songs.id, albums.id, artists.id + \\GROUP BY songs.id, artists.id \\ORDER BY scrobbles DESC, songs.name ASC , .album => @@ -420,21 +419,6 @@ pub fn loadQuery(entity: EntityType, query_type: QueryTypeEnum) GeneratedQuery { , .scrobble => unreachable, }, - .entities_by_name => switch (entity) { - .song => - \\SELECT songs.name AS song_name, songs.id AS song_id, albums.name AS album_name, albums.id AS album_id, artists.name AS artist_name, artists.id AS artist_id, COUNT(scrobbles) AS scrobbles - \\FROM albumsongs - \\INNER JOIN songs ON albumsongs.song_id = songs.id - \\INNER JOIN scrobbles ON scrobbles.albumsong = albumsongs.id - \\INNER JOIN albumsongsartists ON albumsongsartists.albumsong_id = albumsongs.id - \\INNER JOIN artists ON artists.id = albumsongsartists.artist_id - \\INNER JOIN albums ON albums.id = albumsongs.album_id - \\WHERE LOWER(songs.name) LIKE LOWER($1) - \\GROUP BY songs.id, albums.id, artists.id - \\ORDER BY songs.name ASC, scrobbles DESC; - , - else => unreachable, - }, }, }; }