╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ event.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
1035 try std.json.Stringify.value(event, .{}, &json.writer); 1036 1037 // commit the event into a special branch 1038 _ = try repo.commitAtRef(io, allocator, .{ .message = json.written() }, null, .{ .kind = .head, .name = "haxy/meta" }); 1039 } 1040 } 1041 1042 // 1043 // consume the user removal into the database 1044 // 1045 1046 { 1047 try evt.consume(repo_opts, io, allocator, &repo, .{ .kind = .head, .name = "haxy/meta" }); 1048 1049 const history = try Repo.DB.ArrayList(.read_only).init(repo.core.db.rootCursor().readOnly()); 1050 1051 // read the moment we just created 1052 const moment_cursor = try history.getCursor(-1) orelse return error.NotFound; 1053 const moment = try Repo.DB.HashMap(.read_only).init(moment_cursor); 1054 1055 // get the last object id 1056 const last_object_id_cursor = try moment.getCursor(hash.hashInt(repo_opts.hash, "haxy-last-object-id")) orelse return error.NotFound; 1057 var last_object_id: [hash.byteLen(repo_opts.hash)]u8 = undefined; 1058 _ = try last_object_id_cursor.readBytes(&last_object_id); 1059 1060 const haxy_cursor = try moment.getCursor(hash.hashInt(repo_opts.hash, "haxy")) orelse return error.NotFound; 1061 const haxy = try Repo.DB.ArrayList(.read_only).init(haxy_cursor); 1062 1063 try std.testing.expectEqual(3, try haxy.count()); 1064 1065 const haxy_moments_cursor = try haxy.getCursor(-1) orelse return error.NotFound; 1066 const haxy_moments = try Repo.DB.HashMap(.read_only).init(haxy_moments_cursor); 1067 1068 const haxy_moment_cursor = try haxy_moments.getCursor(hash.bytesToInt(repo_opts.hash, &last_object_id)) orelse return error.NotFound; 1069 const haxy_moment = try Repo.DB.HashMap(.read_only).init(haxy_moment_cursor); 1070 1071 // get the map of users 1072 const event_id_to_user_cursor = try haxy_moment.getCursor(hash.hashInt(repo_opts.hash, "event-id->user")) orelse return error.NotFound; 1073 const event_id_to_user = try Repo.DB.HashMap(.read_only).init(event_id_to_user_cursor); 1074 1075 try std.testing.expect(null == try event_id_to_user.getCursor(hash.hashInt(repo_opts.hash, &user_event_id))); 1076 } 1077 } 1078