╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Issue.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
301 // the issue `id_bytes` names in the repo's consumed event db (the repo's own 302 // db for xit; the side db next to a git repo), or null 303 fn readById( 304 comptime repo_kind: rp.RepoKind, 305 comptime repo_opts: rp.RepoOpts(repo_kind), 306 io: std.Io, 307 allocator: std.mem.Allocator, 308 arena: *std.heap.ArenaAllocator, 309 repo: *rp.Repo(repo_kind, repo_opts), 310 id_bytes: *const [evt.event_id_size]u8, 311 ) !?Record { 312 const DB = evt.EventDB(repo_opts.hash); 313 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; 314 defer if (event_db_maybe) |*event_db| event_db.deinit(io, allocator); 315 const moment = (if (event_db_maybe) |*event_db| 316 evt.currentMomentFromDb(repo_opts.hash, event_db.db) 317 else if (repo_kind == .git) 318 return null 319 else 320 evt.currentMoment(repo_opts, repo)) catch return null; 321 const event_id_to_issue_cursor = (try moment.getCursor(hash.hashInt(repo_opts.hash, record_map_key))) orelse return null; 322 const event_id_to_issue = try DB.HashMap(.read_only).init(event_id_to_issue_cursor); 323 const issue_cursor = (try event_id_to_issue.getCursor(hash.hashInt(repo_opts.hash, id_bytes))) orelse return null; 324 const issue_map = try DB.HashMap(.read_only).init(issue_cursor); 325 return try evt.read(Record, DB, repo_opts.hash, arena, issue_map); 326 } 327 328 // remove an issue's order key from its labels' `status` sets, pruning entries 329 // whose set becomes empty 330 fn removeFromLabelSets( 331 comptime DB: type, 332 label_to_issues: DB.SortedMap(.read_write), 333 labels: []const u8, 334 status: Status, 335 order_key: []const u8, 336 ) !void { 337 var label_iter = labelIterator(labels); 338 while (label_iter.next()) |label| { 339 // skipped the same way consume skipped it, so it was never indexed 340 if (label.len == 0 or label.len > label_max_len) continue; 341 var key_buffer: LabelStatusKey = undefined; 342 const key = try labelStatusKey(&key_buffer, label, status); 343 const label_set_cursor = try label_to_issues.putCursor(key); 344 const label_set = try DB.SortedSet(.read_write).init(label_set_cursor); 345 _ = try label_set.remove(order_key); 346 if (0 == try label_set.count()) _ = try label_to_issues.remove(key); 347 } 348 } 349