╭ changed ────╮ │src/event.zig│ ╰─────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1511 return std.meta.stringToEnum(EventKind, try cursor.readBytes(&buffer)) orelse error.InvalidEventKind; │ │1512 } │ │1513 │ │1514 +// the email of the event's author, or null when the id names no authored event │ │1515 +// of this kind │ │1516 +pub fn readAuthorEmail( │ │1517 + comptime repo_kind: rp.RepoKind, │ │1518 + comptime repo_opts: rp.RepoOpts(repo_kind), │ │1519 + io: std.Io, │ │1520 + allocator: std.mem.Allocator, │ │1521 + arena: *std.heap.ArenaAllocator, │ │1522 + repo: *rp.Repo(repo_kind, repo_opts), │ │1523 + kind: EventKind, │ │1524 + id: *const [event_id_size]u8, │ │1525 +) !?[]const u8 { │ │1526 + const record_map_key = switch (kind) { │ │1527 + .issue => Issue.record_map_key, │ │1528 + .discuss => Discussion.record_map_key, │ │1529 + .comment => Comment.record_map_key, │ │1530 + .attach => Attachment.record_map_key, │ │1531 + .patchrev => PatchRev.record_map_key, │ │1532 + .patch => Patch.record_map_key, │ │1533 + .user, .repo, .fork => return null, │ │1534 + }; │ │1535 + │ │1536 + const DB = EventDB(repo_opts.hash); │ │1537 + var event_db_maybe: ?LocalEventDB(repo_opts.hash) = if (repo_kind == .git) try LocalEventDB(repo_opts.hash).openReadOnly(io, allocator, repo.core.repo_dir) else null;│ │1538 + defer if (event_db_maybe) |*event_db| event_db.deinit(io, allocator); │ │1539 + const moment = (if (event_db_maybe) |*event_db| │ │1540 + currentMomentFromDb(repo_opts.hash, event_db.db) │ │1541 + else if (repo_kind == .git) │ │1542 + return null │ │1543 + else │ │1544 + currentMoment(repo_opts, repo)) catch return null; │ │1545 + │ │1546 + const records_cursor = (try moment.getCursor(hash.hashInt(repo_opts.hash, record_map_key))) orelse return null; │ │1547 + const records = try DB.HashMap(.read_only).init(records_cursor); │ │1548 + const record_cursor = (try records.getCursor(hash.hashInt(repo_opts.hash, id))) orelse return null; │ │1549 + const record = try DB.HashMap(.read_only).init(record_cursor); │ │1550 + return try readField(?[]const u8, DB, repo_opts.hash, arena, try record.getCursor(hash.hashInt(repo_opts.hash, "author_email"))); │ │1551 +} │ │1552 + │ │1553 // the event id embedded in a set entry's order key │ │1554 pub fn readOrderKeyId(comptime DB: type, kv_pair_cursor: DB.Cursor(.read_only)) ![event_id_size]u8 { │ │1555 var cursor = kv_pair_cursor; │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯