╭──────────╮ │← previous│ ╰──────────╯ ╭ changed ────╮ │src/event.zig│ ╰─────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────╮ │352 if (issue_data_maybe) |issue_data| { │ │353 const issue_cursor = try event_id_to_issue.putCursor(issue_key); │ │354 const issue = try DB.HashMap(.read_write).init(issue_cursor); │ │447 - try upsert(DB, repo_opts.hash, issue, EventData.Issue, issue_data); │ │355 + try upsert(DB, repo_opts.hash, issue, Issue, issue_data); │ │356 } else { │ │357 if (!try event_id_to_issue.remove(issue_key)) return error.EventNotFound;│ │358 } │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │371 try state.extra.moment.put(hash.hashInt(repo_opts.hash, "haxy-last-object-id"), .{ .bytes = last_object_id });│ │372 } │ │373 } │ │374 + │ │375 +// │ │376 +// reading from xitdb │ │377 +// │ │378 │ │379 +pub fn readBytes( │ │380 + comptime DB: type, │ │381 + comptime hash_kind: hash.HashKind, │ │382 + allocator: std.mem.Allocator, │ │383 + map: DB.HashMap(.read_only), │ │384 + field_name: []const u8, │ │385 +) ![]const u8 { │ │386 + const cursor = try map.getCursor(hash.hashInt(hash_kind, field_name)) orelse return error.NotFound; │ │387 + return try cursor.readBytesAlloc(allocator, null); │ │388 +} │ │389 + │ │390 +pub fn readBool( │ │391 + comptime DB: type, │ │392 + comptime hash_kind: hash.HashKind, │ │393 + map: DB.HashMap(.read_only), │ │394 + field_name: []const u8, │ │395 +) !bool { │ │396 + const cursor = try map.getCursor(hash.hashInt(hash_kind, field_name)) orelse return error.NotFound; │ │397 + var buffer: [5]u8 = undefined; │ │398 + const bytes = try cursor.readBytesObject(&buffer); │ │399 + const format_tag = bytes.format_tag orelse return error.InvalidFormatTag; │ │400 + if (!std.mem.eql(u8, &format_tag, "bl")) return error.InvalidFormatTag; │ │401 + if (std.mem.eql(u8, bytes.value, "true")) return true; │ │402 + if (std.mem.eql(u8, bytes.value, "false")) return false; │ │403 + return error.InvalidBool; │ │404 +} │ │405 + │ │406 +// │ │407 +// writing to xitdb │ │408 +// │ │409 + │ │410 fn upsert( │ │411 comptime DB: type, │ │412 comptime hash_kind: hash.HashKind, │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭ removed ─────────╮ │src/event/user.zig│ ╰──────────────────╯ ╭ added ────────────╮ │src/event/Issue.zig│ ╰───────────────────╯ ╭ added ───────────╮ │src/event/Repo.zig│ ╰──────────────────╯ ╭ added ───────────╮ │src/event/User.zig│ ╰──────────────────╯ ╭ changed ─────────╮ │src/test/event.zig│ ╰──────────────────╯ ╭──────────────────────────────╮ │1 const std = @import("std");│ │2 const hx = @import("haxy");│ │3 const evt = hx.event; │ │4 -const usr = evt.user; │ │4 const xit = hx.xit; │ │5 const rp = xit.repo; │ │6 const hash = xit.hash; │ ╰──────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────╮ │41 │ │42 var prng = std.Random.DefaultPrng.init(std.testing.random_seed);│ │43 │ │45 - const first_event_id = evt.randomId(prng.random()); │ │44 + const first_event_id = evt.Event.randomId(prng.random()); │ │45 │ │46 const events_to_consume = [_]evt.Event{ │ │47 .{ │ ╰────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────╮ │66 }, │ │67 }, │ │68 .{ │ │70 - .id = std.fmt.bytesToHex(evt.randomId(prng.random()), .lower), │ │69 + .id = std.fmt.bytesToHex(evt.Event.randomId(prng.random()), .lower),│ │70 .data = .{ │ │71 .issue = .{ │ │72 .title = "Search results ignore archived project filter", │ ╰────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────╮ │76 }, │ │77 }, │ │78 .{ │ │80 - .id = std.fmt.bytesToHex(evt.randomId(prng.random()), .lower), │ │79 + .id = std.fmt.bytesToHex(evt.Event.randomId(prng.random()), .lower),│ │80 .data = .{ │ │81 .issue = .{ │ │82 .title = "Issue list does not persist selected sort order", │ ╰────────────────────────────────────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯