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