╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Discussion.zig ───────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
173 .title = title, 174 .tags = tags, 175 .description = description, 176 } }, 177 }}); 178 } 179 180 fn removeFromTagSets(comptime DB: type, tags: DB.SortedMap(.read_write), names: []const u8, order_key: []const u8) !void { 181 var tag_iter = tagIterator(names); 182 while (tag_iter.next()) |tag| { 183 if (tag.len == 0 or tag.len > tag_max_len) continue; 184 const cursor = try tags.putCursor(tag); 185 const set = try DB.SortedSet(.read_write).init(cursor); 186 _ = try set.remove(order_key); 187 if (0 == try set.count()) _ = try tags.remove(tag); 188 } 189 } 190 191 fn addToTagSets(comptime DB: type, tags: DB.SortedMap(.read_write), names: []const u8, order_key: []const u8) !void { 192 var tag_iter = tagIterator(names); 193 while (tag_iter.next()) |tag| { 194 if (tag.len == 0 or tag.len > tag_max_len) continue; 195 const set = try DB.SortedSet(.read_write).init(try tags.putCursor(tag)); 196 try set.put(order_key); 197 } 198 } 199 200 pub fn readById( 201 comptime repo_kind: rp.RepoKind, 202 comptime repo_opts: rp.RepoOpts(repo_kind), 203 io: std.Io, 204 allocator: std.mem.Allocator, 205 arena: *std.heap.ArenaAllocator, 206 repo: *rp.Repo(repo_kind, repo_opts), 207 id: *const [evt.event_id_size]u8, 208 ) !?Record { 209 const DB = evt.EventDB(repo_opts.hash); 210 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; 211 defer if (event_db_maybe) |*event_db| event_db.deinit(io, allocator); 212 const moment = (if (event_db_maybe) |*event_db| 213 evt.currentMomentFromDb(repo_opts.hash, event_db.db) 214 else if (repo_kind == .git) 215 return null 216 else 217 evt.currentMoment(repo_opts, repo)) catch return null; 218 const records_cursor = try moment.getCursor(hash.hashInt(repo_opts.hash, record_map_key)) orelse return null; 219 const records = try DB.HashMap(.read_only).init(records_cursor); 220 const record_cursor = try records.getCursor(hash.hashInt(repo_opts.hash, id)) orelse return null; 221 return try evt.read(Record, DB, repo_opts.hash, arena, try DB.HashMap(.read_only).init(record_cursor)); 222 } 223