╭ changed ─────────╮ │src/event/User.zig│ ╰──────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │211 arena: *std.heap.ArenaAllocator, │ │212 user_id: []const u8, │ │213 ) !?Record { │ │214 - const event_id_to_user_cursor = try haxy_moment.getCursor(hash.hashInt(hash_kind, "event-id->user")) orelse return null;│ │215 - const event_id_to_user = try DB.HashMap(.read_only).init(event_id_to_user_cursor); │ │216 - const user_cursor = try event_id_to_user.getCursor(hash.hashInt(hash_kind, user_id)) orelse return null; │ │217 - const user_map = try DB.HashMap(.read_only).init(user_cursor); │ │214 + const user_map = try userMap(DB, hash_kind, haxy_moment, user_id) orelse return null; │ │215 return try evt.read(Record, DB, hash_kind, arena, user_map); │ │216 } │ │217 │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────╮ │221 -// read a user by email via the email->user-id index, or null when no user has │ │222 -// the email. field byte slices are allocated in `arena`. │ │218 +// read just the public part of a user by email via the email->user-id index, or│ │219 +// null when no user has the email. field byte slices are allocated in `arena`. │ │220 pub fn readByEmail( │ │221 comptime DB: type, │ │222 comptime hash_kind: hash.HashKind, │ ╰─────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │223 haxy_moment: DB.HashMap(.read_only), │ │224 arena: *std.heap.ArenaAllocator, │ │225 email: []const u8, │ │229 -) !?Record { │ │226 +) !?Public { │ │227 const email_to_user_id_cursor = (try haxy_moment.getCursor(hash.hashInt(hash_kind, email_to_user_id_key))) orelse return null;│ │228 const email_to_user_id = try DB.HashMap(.read_only).init(email_to_user_id_cursor); │ │229 const user_id_cursor = (try email_to_user_id.getCursor(hash.hashInt(hash_kind, email))) orelse return null; │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │230 var user_id: [evt.event_id_size]u8 = undefined; │ │231 _ = try user_id_cursor.readBytes(&user_id); │ │235 - return try readById(DB, hash_kind, haxy_moment, arena, &user_id); │ │232 + const user_map = try userMap(DB, hash_kind, haxy_moment, &user_id) orelse return null; │ │233 + const record = try evt.read(struct { event: Public }, DB, hash_kind, arena, user_map); │ │234 + return record.event; │ │235 +} │ │236 + │ │237 +// a user's record map via the event-id->user index │ │238 +fn userMap( │ │239 + comptime DB: type, │ │240 + comptime hash_kind: hash.HashKind, │ │241 + haxy_moment: DB.HashMap(.read_only), │ │242 + user_id: []const u8, │ │243 +) !?DB.HashMap(.read_only) { │ │244 + const event_id_to_user_cursor = try haxy_moment.getCursor(hash.hashInt(hash_kind, "event-id->user")) orelse return null;│ │245 + const event_id_to_user = try DB.HashMap(.read_only).init(event_id_to_user_cursor); │ │246 + const user_cursor = try event_id_to_user.getCursor(hash.hashInt(hash_kind, user_id)) orelse return null; │ │247 + return try DB.HashMap(.read_only).init(user_cursor); │ │248 } │ │249 │ │250 // read a user by name from the admin event store, or null if the admin repo or │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭ changed ─╮ │src/ui.zig│ ╰──────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │2601 const email = author_email orelse return .unknown; │ │2602 if (haxy_moment) |moment| { │ │2603 if (try evt.User.readByEmail(evt.AdminDB, evt.admin_repo_opts.hash, moment, arena, email)) |user| {│ │2604 - return .{ .user_name = user.event.name }; │ │2604 + return .{ .user_name = user.name }; │ │2605 } │ │2606 } │ │2607 return .{ .email = try arena.allocator().dupe(u8, email) }; │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯