╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Repo.zig ─────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
210 211 // "user-id/repo-name" -> repo event id 212 const repo_path = try (Record{ .event = .{ .user_id = user_id[0..], .name = repo_name, .description = "" } }).indexKey(arena.allocator()); 213 const name_to_repo_id_cursor = try haxy_moment.getCursor(hash.hashInt(hash_kind, "name->repo-id")) orelse return null; 214 const name_to_repo_id = try DB.HashMap(.read_only).init(name_to_repo_id_cursor); 215 const repo_id_cursor = try name_to_repo_id.getCursor(hash.hashInt(hash_kind, repo_path)) orelse return null; 216 var repo_id: [evt.event_id_size]u8 = undefined; 217 _ = try repo_id_cursor.readBytes(&repo_id); 218 219 const event_id_to_repo_cursor = try haxy_moment.getCursor(hash.hashInt(hash_kind, "event-id->repo")) orelse return null; 220 const event_id_to_repo = try DB.HashMap(.read_only).init(event_id_to_repo_cursor); 221 const repo_cursor = try event_id_to_repo.getCursor(hash.hashInt(hash_kind, &repo_id)) orelse return null; 222 const repo_map = try DB.HashMap(.read_only).init(repo_cursor); 223 return .{ .repo = try evt.read(Record, DB, hash_kind, arena, repo_map), .event_id = repo_id }; 224 } 225 226 pub fn readById( 227 comptime DB: type, 228 comptime hash_kind: hash.HashKind, 229 haxy_moment: DB.HashMap(.read_only), 230 arena: *std.heap.ArenaAllocator, 231 id: []const u8, 232 ) !?Record { 233 const records_cursor = try haxy_moment.getCursor(hash.hashInt(hash_kind, record_map_key)) orelse return null; 234 const records = try DB.HashMap(.read_only).init(records_cursor); 235 const record_cursor = try records.getCursor(hash.hashInt(hash_kind, id)) orelse return null; 236 return try evt.read(Record, DB, hash_kind, arena, try DB.HashMap(.read_only).init(record_cursor)); 237 } 238