╭ changed ─────────╮ │src/event/Repo.zig│ ╰──────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │37 │ │38 // if this event_id already maps to a repo under a different key (its │ │39 // name or owner changed), drop the stale name->id entry first │ │40 - if (try event_id_to_repo.getCursor(repo_key)) |existing_cursor| { │ │40 + const existing_cursor_maybe = try event_id_to_repo.getCursor(repo_key); │ │41 + if (existing_cursor_maybe) |existing_cursor| { │ │42 const existing_repo = try DB.HashMap(.read_only).init(existing_cursor); │ │43 const existing_event = try evt.read(@This(), DB, hash_kind, arena, existing_repo); │ │44 const existing_path = try std.fmt.allocPrint(arena.allocator(), "{s}/{s}", .{ existing_event.user_id, existing_event.name });│ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │53 │ │54 try name_to_repo_id.put(hash.hashInt(hash_kind, repo_path), .{ .bytes = event_id }); │ │55 │ │56 + // first time we've seen this repo: append its id to the ordered list │ │57 + // the repos view paginates through (a delete leaves a tombstone here). │ │58 + if (existing_cursor_maybe == null) { │ │59 + const repo_list_cursor = try haxy_moment.putCursor(hash.hashInt(hash_kind, "repo-list")); │ │60 + const repo_list = try DB.ArrayList(.read_write).init(repo_list_cursor); │ │61 + try repo_list.append(.{ .bytes = event_id }); │ │62 + } │ │63 + │ │64 const user_id_to_repos_cursor = try haxy_moment.putCursor(hash.hashInt(hash_kind, "user-id->repos"));│ │65 const user_id_to_repos = try DB.HashMap(.read_write).init(user_id_to_repos_cursor); │ │66 │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯