╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Assignment.zig ───────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
143 pub fn readById( 144 comptime DB: type, 145 comptime hash_kind: hash.HashKind, 146 haxy_moment: DB.HashMap(.read_only), 147 arena: *std.heap.ArenaAllocator, 148 assignment_id: []const u8, 149 ) !?Record { 150 return try evt.readRecordSubset(Self, Record, DB, hash_kind, haxy_moment, arena, assignment_id); 151 } 152 153 // the emails assigned to a thread, oldest first 154 pub fn load( 155 comptime hash_kind: hash.HashKind, 156 arena: *std.heap.ArenaAllocator, 157 haxy_moment: evt.EventDB(hash_kind).HashMap(.read_only), 158 thread_id: []const u8, 159 ) ![]const []const u8 { 160 const DB = evt.EventDB(hash_kind); 161 var emails: std.ArrayList([]const u8) = .empty; 162 const index_cursor = try haxy_moment.getCursor(hash.hashInt(hash_kind, thread_id_to_assignment_id_set_key)) orelse return emails.items; 163 const index = try DB.HashMap(.read_only).init(index_cursor); 164 const set_cursor = try index.getCursor(hash.hashInt(hash_kind, thread_id)) orelse return emails.items; 165 const set = try DB.SortedSet(.read_only).init(set_cursor); 166 167 var iter = try set.iteratorFromIndex(0); 168 while (try iter.next()) |kv_cursor| { 169 const id_bytes = try evt.readOrderKeyId(DB, kv_cursor); 170 const record = (try evt.readRecordSubset(Self, struct { event: struct { email: []const u8 } }, DB, hash_kind, haxy_moment, arena, &id_bytes)) orelse continue; 171 try emails.append(arena.allocator(), record.event.email); 172 } 173 return emails.items; 174 } 175