╭ changed ────╮ │src/event.zig│ ╰─────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────╮ │← previous│ ╰──────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1287 try kind_map.put(hash.hashInt(hash_kind, event_id), .{ .bytes = @tagName(kind) }); │ │1288 │ │1245 - const id_set_cursor = try haxy_moment.putCursor(hash.hashInt(hash_kind, event_id_set_key)); │ │1246 - const id_set = try DB.SortedSet(.read_write).init(id_set_cursor); │ │1247 - try id_set.put(&orderKeyDesc(created_ts, event_id)); │ │1289 + const active_cursor = try haxy_moment.putCursor(hash.hashInt(hash_kind, active_event_id_set_key)); │ │1290 + const active = try DB.SortedSet(.read_write).init(active_cursor); │ │1291 + const removed_cursor = try haxy_moment.putCursor(hash.hashInt(hash_kind, removed_event_id_set_key)); │ │1292 + const removed_set = try DB.SortedSet(.read_write).init(removed_cursor); │ │1293 + const order_key = orderKeyDesc(created_ts, event_id); │ │1294 + if (removed) { │ │1295 + _ = try active.remove(&order_key); │ │1296 + try removed_set.put(&order_key); │ │1297 + } else { │ │1298 + _ = try removed_set.remove(&order_key); │ │1299 + try active.put(&order_key); │ │1300 + } │ │1301 +} │ │1302 + │ │1303 +pub fn readEventKind( │ │1304 + comptime hash_kind: hash.HashKind, │ │1305 + kind_map: anytype, │ │1306 + id: *const [event_id_size]u8, │ │1307 +) !?EventKind { │ │1308 + const cursor = try kind_map.getCursor(hash.hashInt(hash_kind, id)) orelse return null; │ │1309 + var buffer: [64]u8 = undefined; │ │1310 + return std.meta.stringToEnum(EventKind, try cursor.readBytes(&buffer)) orelse error.InvalidEventKind;│ │1311 } │ │1312 │ │1313 // the event id embedded in a set entry's order key │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────╯