Update Search view

This commit is contained in:
Samuel Webb 2024-04-10 23:48:22 -04:00
parent 75a63a19fc
commit 8f34815904
4 changed files with 24 additions and 25 deletions

View file

@ -14,20 +14,16 @@
// `zig build --fetch` can be used to fetch all dependencies of a package, recursively.
// Once all dependencies are fetched, `zig build` no longer requires
// internet connectivity.
.dependencies = .{
.jetzig = .{
.url = "https://github.com/jetzig-framework/jetzig/archive/68ca4d3bbad05880e6e38fc6d10e7a24e772081e.tar.gz",
.hash = "122047ebabab1dfe1bb7f96ffdac98410ffb4850b06dc6b1670ce74aaeaa49bdc08e",
},
.iguanas = .{
.url = "https://github.com/jetzig-framework/iguanas/archive/89c2abf29de0bc31054a9a6feac5a6a83bab0459.tar.gz",
.hash = "12202fd319a5ab4e124b00e8ddea474d07c19c4e005d77b6c29fc44860904ea01a5c",
},
.sqlite = .{
.url = "https://github.com/vrischmann/zig-sqlite/archive/6af21bb.tar.gz",
.hash = "12202799861d92c7880d1a74f95be099752d7f0420a0c9628dc923ca2b1a22b7bda8",
}
},
.dependencies = .{ .jetzig = .{
.url = "https://github.com/jetzig-framework/jetzig/archive/88abe2243d87b28ad110c5fe9fe90b716a6c6583.tar.gz",
.hash = "12200d15cef72d4c37a01c930db53c3ffafdc05142462afddeab818701a0291327d1",
}, .iguanas = .{
.url = "https://github.com/jetzig-framework/iguanas/archive/89c2abf29de0bc31054a9a6feac5a6a83bab0459.tar.gz",
.hash = "12202fd319a5ab4e124b00e8ddea474d07c19c4e005d77b6c29fc44860904ea01a5c",
}, .sqlite = .{
.url = "https://github.com/vrischmann/zig-sqlite/archive/6af21bb.tar.gz",
.hash = "12202799861d92c7880d1a74f95be099752d7f0420a0c9628dc923ca2b1a22b7bda8",
} },
.paths = .{
// This makes *all* files, recursively, included in this package. It is generally
// better to explicitly list the files and directories instead, to insure that

View file

@ -13,5 +13,5 @@ pub const getTrack = \\SELECT artist, track, album, plays FROM tracks WHERE trac
pub const getTrackSearch = \\SELECT url FROM artists WHERE artist == ?
;
pub const getArtistSearch = \\SELECT artist, plays FROM artists WHERE artist LIKE '%' || ? || '%'
pub const getArtistSearch = \\SELECT artist, url FROM artists WHERE artist LIKE '%' || ? || '%'
;

View file

@ -27,7 +27,7 @@ pub fn index(request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
const artistResults = try artistSearch.all(
struct {
artist: []u8,
url: usize,
url: []u8,
},
arena.allocator(),
.{},
@ -36,8 +36,8 @@ pub fn index(request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
for (artistResults) |r| {
std.log.debug("artist: {s}, url: {s}", .{ r.artist, r.url });
root.append(data.string(r.artist));
root.append(data.string(r.url));
try root.append(data.string(r.artist));
try root.append(data.string(r.url));
//std.log.debug("{s}", .{r});
}
} else {

View file

@ -4,12 +4,15 @@
<th>Album</th>
<th>Track</th>
</tr>
<tr>
@zig {
for (0..)
<td id="artistUpdate"></td>
<td id="albumUpdate"></td>
<td id="trackUpdate"></td>
@zig ZIG
for (zmpl.items(.array), 0..) |u,i| {
if(@mod(i,2)==0){
<tr>
<td id="artistUpdate"><a href={{zmpl.items(.array)[i+1].string.value}}>{{u}}</a></td>
<td id="albumUpdate">{{i}}</td>
<td id="trackUpdate"></td>
</tr>
}
}
</tr>
ZIG
</table>