╭ changed ─────────╮ │src/event/Repo.zig│ ╰──────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │50 // the index is keyed by "user-id/repo-name": a repo is unique per │ │51 // owner, and the read side resolves the url's username to its user id. │ │52 const repo_path = try std.fmt.allocPrint(arena.allocator(), "{s}/{s}", .{ event.user_id, event.name }); │ │53 + │ │54 + const user_id_to_repo_id_set_cursor = try haxy_moment.putCursor(hash.hashInt(hash_kind, "user-id->repo-id-set"));│ │55 + const user_id_to_repo_id_set = try DB.HashMap(.read_write).init(user_id_to_repo_id_set_cursor); │ │56 │ │57 // if this event_id already maps to a repo under a different key (its │ │55 - // name or owner changed), drop the stale name->id entry first │ │58 + // name or owner changed), drop the stale index entries first │ │59 const existing_cursor_maybe = try event_id_to_repo.getCursor(repo_key); │ │60 if (existing_cursor_maybe) |existing_cursor| { │ │61 const existing_repo = try DB.HashMap(.read_only).init(existing_cursor); │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │65 const existing_path = try std.fmt.allocPrint(arena.allocator(), "{s}/{s}", .{ existing_event.user_id, existing_event.name });│ │66 if (!std.mem.eql(u8, existing_path, repo_path)) { │ │67 _ = try name_to_repo_id.remove(hash.hashInt(hash_kind, existing_path)); │ │68 + } │ │69 + if (!std.mem.eql(u8, existing_event.user_id, event.user_id)) { │ │70 + const old_user_repos_cursor = try user_id_to_repo_id_set.putCursor(hash.hashInt(hash_kind, existing_event.user_id)); │ │71 + const old_user_repos = try DB.SortedSet(.read_write).init(old_user_repos_cursor); │ │72 + const order_key = evt.orderKey(existing_event.created_ts, event_id); │ │73 + _ = try old_user_repos.remove(&order_key); │ │74 } │ │75 } else { │ │76 // first time we've seen this repo: stamp it with the commit timestamp │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │93 try repo_id_set.put(&order_key); │ │94 } │ │95 │ │87 - const user_id_to_repo_id_set_cursor = try haxy_moment.putCursor(hash.hashInt(hash_kind, "user-id->repo-id-set"));│ │88 - const user_id_to_repo_id_set = try DB.HashMap(.read_write).init(user_id_to_repo_id_set_cursor); │ │89 - │ │96 // each user's repos are a set ordered by creation time (oldest first), so │ │97 // the user page paginates them the same way the home repos list does. │ │98 const user_repos_cursor = try user_id_to_repo_id_set.putCursor(hash.hashInt(hash_kind, event.user_id)); │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯