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