╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Assignment.zig ───────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭ find file ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ ╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ │ │ │http│ ssh │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯
178 comptime DB: type, 179 comptime hash_kind: hash.HashKind, 180 haxy_moment: DB.HashMap(.read_only), 181 arena: *std.heap.ArenaAllocator, 182 assignment_id: []const u8, 183 ) !?Record { 184 return try evt.readRecordSubset(Self, Record, DB, hash_kind, haxy_moment, arena, assignment_id); 185 } 186 187 // the emails assigned to a thread, oldest first 188 pub fn load( 189 comptime hash_kind: hash.HashKind, 190 arena: *std.heap.ArenaAllocator, 191 haxy_moment: evt.EventDB(hash_kind).HashMap(.read_only), 192 thread_id: *const [evt.event_id_size]u8, 193 ) ![]const []const u8 { 194 const DB = evt.EventDB(hash_kind); 195 var emails: std.ArrayList([]const u8) = .empty; 196 const index_cursor = try haxy_moment.getCursor(hash.hashInt(hash_kind, thread_id_to_assignment_id_set_key)) orelse return emails.items; 197 const index = try DB.HashMap(.read_only).init(index_cursor); 198 const set_cursor = try index.getCursor(hash.hashInt(hash_kind, thread_id)) orelse return emails.items; 199 const set = try DB.SortedSet(.read_only).init(set_cursor); 200 201 var iter = try set.iteratorFromIndex(0); 202 while (try iter.next()) |kv_cursor| { 203 const id_bytes = try evt.readOrderKeyId(DB, kv_cursor); 204 const record = (try evt.readRecordSubset(Self, struct { event: struct { email: []const u8 } }, DB, hash_kind, haxy_moment, arena, &id_bytes)) orelse continue; 205 try emails.append(arena.allocator(), record.event.email); 206 } 207 return emails.items; 208 } 209