╭ changed ─────────╮ │src/event/Repo.zig│ ╰──────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │74 │ │75 try name_to_repo_id.put(hash.hashInt(hash_kind, repo_path), .{ .bytes = event_id }); │ │76 │ │77 - // first time we've seen this repo: add it to the ordered map the repos │ │78 - // view paginates through │ │77 + // first time we've seen this repo: add it to the ordered set the repos │ │78 + // view paginates through. the key (orderKey) embeds the event id, so the │ │79 + // set needs no value. │ │80 if (existing_cursor_maybe == null) { │ │80 - const created_ts_to_repo_id_cursor = try haxy_moment.putCursor(hash.hashInt(hash_kind, "created-ts->repo-id"));│ │81 - const created_ts_to_repo_id = try DB.SortedMap(.read_write).init(created_ts_to_repo_id_cursor); │ │81 + const repo_id_set_cursor = try haxy_moment.putCursor(hash.hashInt(hash_kind, "repo-id-set")); │ │82 + const repo_id_set = try DB.SortedSet(.read_write).init(repo_id_set_cursor); │ │83 const order_key = evt.orderKey(event_to_write.created_ts, event_id); │ │83 - try created_ts_to_repo_id.put(&order_key, .{ .bytes = event_id }); │ │84 + try repo_id_set.put(&order_key); │ │85 } │ │86 │ │86 - const user_id_to_repos_cursor = try haxy_moment.putCursor(hash.hashInt(hash_kind, "user-id->repos")); │ │87 - const user_id_to_repos = try DB.HashMap(.read_write).init(user_id_to_repos_cursor); │ │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 │ │89 - const user_repos_cursor = try user_id_to_repos.putCursor(hash.hashInt(hash_kind, event.user_id)); │ │90 - const user_repos = try DB.CountedHashSet(.read_write).init(user_repos_cursor); │ │91 - try user_repos.put(repo_key, .{ .bytes = event_id }); │ │90 + // each user's repos are a set ordered by creation time (oldest first), so │ │91 + // the user page paginates them the same way the home repos list does. │ │92 + const user_repos_cursor = try user_id_to_repo_id_set.putCursor(hash.hashInt(hash_kind, event.user_id)); │ │93 + const user_repos = try DB.SortedSet(.read_write).init(user_repos_cursor); │ │94 + const user_repo_order_key = evt.orderKey(event_to_write.created_ts, event_id); │ │95 + try user_repos.put(&user_repo_order_key); │ │96 } else { │ │97 if (try event_id_to_repo.getCursor(repo_key)) |existing_repo_cursor| { │ │98 const existing_repo = try DB.HashMap(.read_only).init(existing_repo_cursor); │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │101 const existing_path = try std.fmt.allocPrint(arena.allocator(), "{s}/{s}", .{ existing_repo_event.user_id, existing_repo_event.name });│ │102 _ = try name_to_repo_id.remove(hash.hashInt(hash_kind, existing_path)); │ │103 │ │100 - // drop it from the ordered map using its recorded creation timestamp │ │101 - const created_ts_to_repo_id_cursor = try haxy_moment.putCursor(hash.hashInt(hash_kind, "created-ts->repo-id")); │ │102 - const created_ts_to_repo_id = try DB.SortedMap(.read_write).init(created_ts_to_repo_id_cursor); │ │104 + // drop it from the ordered set using its recorded creation timestamp │ │105 + const repo_id_set_cursor = try haxy_moment.putCursor(hash.hashInt(hash_kind, "repo-id-set")); │ │106 + const repo_id_set = try DB.SortedSet(.read_write).init(repo_id_set_cursor); │ │107 const order_key = evt.orderKey(existing_repo_event.created_ts, event_id); │ │104 - _ = try created_ts_to_repo_id.remove(&order_key); │ │108 + _ = try repo_id_set.remove(&order_key); │ │109 │ │106 - const user_id_to_repos_cursor = try haxy_moment.putCursor(hash.hashInt(hash_kind, "user-id->repos")); │ │107 - const user_id_to_repos = try DB.HashMap(.read_write).init(user_id_to_repos_cursor); │ │110 + const user_id_to_repo_id_set_cursor = try haxy_moment.putCursor(hash.hashInt(hash_kind, "user-id->repo-id-set")); │ │111 + const user_id_to_repo_id_set = try DB.HashMap(.read_write).init(user_id_to_repo_id_set_cursor); │ │112 │ │113 const user_key = hash.hashInt(hash_kind, existing_repo_event.user_id); │ │110 - const user_repos_cursor = try user_id_to_repos.putCursor(user_key); │ │111 - const user_repos = try DB.CountedHashSet(.read_write).init(user_repos_cursor); │ │112 - _ = try user_repos.remove(repo_key); │ │114 + const user_repos_cursor = try user_id_to_repo_id_set.putCursor(user_key); │ │115 + const user_repos = try DB.SortedSet(.read_write).init(user_repos_cursor); │ │116 + _ = try user_repos.remove(&order_key); │ │117 } │ │118 if (!try event_id_to_repo.remove(repo_key)) return error.EventNotFound; │ │119 } │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯