╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Issue.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
195 comptime repo_opts: rp.RepoOpts(repo_kind), 196 io: std.Io, 197 allocator: std.mem.Allocator, 198 arena: *std.heap.ArenaAllocator, 199 repo: *rp.Repo(repo_kind, repo_opts), 200 id_bytes: *const [evt.event_id_size]u8, 201 ) !?@This() { 202 const DB = evt.EventDB(repo_opts.hash); 203 var event_db_maybe: ?evt.LocalEventDB(repo_opts.hash) = if (repo_kind == .git) try evt.LocalEventDB(repo_opts.hash).openReadOnly(io, allocator, repo.core.repo_dir) else null; 204 defer if (event_db_maybe) |*event_db| event_db.deinit(io, allocator); 205 const moment = (if (event_db_maybe) |*event_db| 206 evt.currentMomentFromDb(repo_opts.hash, event_db.db) 207 else if (repo_kind == .git) 208 return null 209 else 210 evt.currentMoment(repo_opts, repo)) catch return null; 211 const event_id_to_issue_cursor = (try moment.getCursor(hash.hashInt(repo_opts.hash, "event-id->issue"))) orelse return null; 212 const event_id_to_issue = try DB.HashMap(.read_only).init(event_id_to_issue_cursor); 213 const issue_cursor = (try event_id_to_issue.getCursor(hash.hashInt(repo_opts.hash, id_bytes))) orelse return null; 214 const issue_map = try DB.HashMap(.read_only).init(issue_cursor); 215 return try evt.read(@This(), DB, repo_opts.hash, arena, issue_map); 216 } 217 218 // remove an issue's order key from its tags' `status` sets, pruning entries 219 // whose set becomes empty 220 fn removeFromTagSets( 221 comptime DB: type, 222 tag_to_issues: DB.SortedMap(.read_write), 223 tags: []const u8, 224 status: Status, 225 order_key: []const u8, 226 ) !void { 227 var tag_iter = tagIterator(tags); 228 while (tag_iter.next()) |tag| { 229 if (tag.len == 0) continue; 230 var key_buffer: TagStatusKey = undefined; 231 const key = try tagStatusKey(&key_buffer, tag, status); 232 const tag_set_cursor = try tag_to_issues.putCursor(key); 233 const tag_set = try DB.SortedSet(.read_write).init(tag_set_cursor); 234 _ = try tag_set.remove(order_key); 235 if (0 == try tag_set.count()) _ = try tag_to_issues.remove(key); 236 } 237 } 238