Begin Scrobbles view

This commit is contained in:
mitteneer 2025-02-25 16:58:39 -05:00
parent 1809a12a8c
commit 692320a1d2
4 changed files with 15 additions and 11 deletions

View file

@ -7,8 +7,12 @@ pub fn index(request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
} }
pub fn get(id: []const u8, request: *jetzig.Request, data: *jetzig.Data) !jetzig.View { pub fn get(id: []const u8, request: *jetzig.Request, data: *jetzig.Data) !jetzig.View {
_ = data; var root = try request.data(.object);
_ = id; const params = try request.params();
if (params.get("ar")) |param| {
const artists = try jetzig.database.Query(.Artists).select(.{.id, .name});
const
}
return request.render(.ok); return request.render(.ok);
} }

View file

@ -1,8 +1,16 @@
<html> <html>
<head>
<link rel="stylesheet" href="styles.css">
</head>
<body> <body>
@partial partials/header @partial partials/header
<div> <div>
<span>Content goes here</span> <span>Look for an artist</span>
</div> </div>
<form action="/scrobbles" method"GET">
<label>Filename</label>
<input type="text" name="ar" />
<input type="submit" value="Submit" />
</form>
</body> </body>
</html> </html>

View file

@ -1,9 +1,6 @@
const std = @import("std"); const std = @import("std");
const jetzig = @import("jetzig"); const jetzig = @import("jetzig");
const jetquery = @import("jetzig").jetquery; const jetquery = @import("jetzig").jetquery;
//const Scrobble = @import("../../types.zig").LastFMScrobble;
//const lastfm = @import("../../types.zig").LastFM;
//const UploadData = @import("../../types").UploadData;
const ScrobbleTypes = @import("../../types.zig"); const ScrobbleTypes = @import("../../types.zig");
const zeit = @import("zeit"); const zeit = @import("zeit");
@ -24,7 +21,6 @@ pub fn post(request: *jetzig.Request) !jetzig.View {
if (try request.file("upload")) |file| { if (try request.file("upload")) |file| {
const params = try request.params(); const params = try request.params();
const source = try std.fmt.parseInt(u8, params.get("t").?.string.value, 10); // This param is required in HTML const source = try std.fmt.parseInt(u8, params.get("t").?.string.value, 10); // This param is required in HTML
// Date limiting is broken atm
const before_limiter: bool = if (params.get("bbool")) |_| true else false; const before_limiter: bool = if (params.get("bbool")) |_| true else false;
const after_limiter: bool = if (params.get("abool")) |_| true else false; const after_limiter: bool = if (params.get("abool")) |_| true else false;
@ -85,8 +81,6 @@ pub fn post(request: *jetzig.Request) !jetzig.View {
continue :appends; continue :appends;
} }
// I'm separating these on account of the above comment, as well as
// this part being kinda complicated
const iso_ts = try zeit.Time.fromISO8601(scrobble.ts); const iso_ts = try zeit.Time.fromISO8601(scrobble.ts);
if ((before_limiter or after_limiter) and (iso_ts.after(before_limiting_date) or iso_ts.before(after_limiting_date))) { if ((before_limiter or after_limiter) and (iso_ts.after(before_limiting_date) or iso_ts.before(after_limiting_date))) {
limited_tracks += 1; limited_tracks += 1;

View file

@ -8,8 +8,6 @@
<span>Upload Last.fm or Spotify history file here (in json format).</span> <span>Upload Last.fm or Spotify history file here (in json format).</span>
</div> </div>
<form action="/upload" enctype="multipart/form-data" method="POST"> <form action="/upload" enctype="multipart/form-data" method="POST">
<label>Filename</label>
<input type="text" name="description" />
<label>File</label> <label>File</label>
<input type="file" name="upload" /> <input type="file" name="upload" />
<input type="submit" value="Submit" /> <input type="submit" value="Submit" />