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