Move Scrobble rule application to upload.zig
They couldn't see the changes made by rules after uploading Scrobbles which made it seem like the rules weren't being applied. Also makes Album rules easier to apply I believe.
This commit is contained in:
parent
87a2fe2d34
commit
77170a1e28
4 changed files with 23 additions and 14 deletions
|
|
@ -18,17 +18,11 @@ const rules = @import("../../apply_rule.zig");
|
|||
// - environment: Enum of `{ production, development }`.
|
||||
pub fn run(allocator: std.mem.Allocator, params: *jetzig.data.Value, env: jetzig.jobs.JobEnv) !void {
|
||||
//_ = env;
|
||||
const file = try std.fs.cwd().openFile("rules.json", .{ .mode = .read_only });
|
||||
const file_content = try file.readToEndAlloc(allocator, 16_000_000);
|
||||
|
||||
const rule_list = try std.json.parseFromSliceLeaky(Data.Rules, allocator, file_content, .{});
|
||||
|
||||
_ = allocator;
|
||||
if (params.getT(.array, "scrobbles")) |scrobbles| {
|
||||
for (scrobbles.items()) |item| {
|
||||
//const fixed_date: u32 = @as(u32, item.getT(.integer, "date").?);
|
||||
const pre_scrobble: Scrobble = .{ .track = item.getT(.string, "track").?, .artist = item.getT(.string, "artist").?, .album = item.getT(.string, "album") orelse "", .date = @as(u64, @bitCast(@as(i64, @truncate(item.getT(.integer, "date").? * 1000)))) };
|
||||
|
||||
const scrobble = rules.applyScrobbleRule(pre_scrobble, rule_list);
|
||||
const scrobble: Scrobble = .{ .track = item.getT(.string, "track").?, .artist = item.getT(.string, "artist").?, .album = item.getT(.string, "album") orelse "", .date = @as(u64, @bitCast(@as(i64, @truncate(item.getT(.integer, "date").? * 1000)))) };
|
||||
|
||||
// Make hashes
|
||||
//const album_hash = @as(i32, @bitCast(std.hash.Fnv1a_32.hash(scrobble.album)));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue