╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Comment.zig ──────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
166 var updated = comment.event; 167 updated.body = body; 168 try evt.consume(.repo, repo_kind, repo_opts, io, allocator, repo, evt.events_ref, &.{.{ 169 .id = std.fmt.bytesToHex(comment_id.*, .lower), 170 .timestamp = @intCast(std.Io.Timestamp.now(io, .real).toSeconds()), 171 .author = author, 172 .event = .{ .comment = updated }, 173 }}); 174 } 175 176 // read a comment by event id, or null if the id isn't a known comment. field 177 // byte slices are allocated in `arena`. 178 pub fn readById( 179 comptime DB: type, 180 comptime hash_kind: hash.HashKind, 181 haxy_moment: DB.HashMap(.read_only), 182 arena: *std.heap.ArenaAllocator, 183 comment_id: []const u8, 184 ) !?Record { 185 const records_cursor = try haxy_moment.getCursor(hash.hashInt(hash_kind, record_map_key)) orelse return null; 186 const records = try DB.HashMap(.read_only).init(records_cursor); 187 const record_cursor = try records.getCursor(hash.hashInt(hash_kind, comment_id)) orelse return null; 188 const record_map = try DB.HashMap(.read_only).init(record_cursor); 189 return try evt.read(Record, DB, hash_kind, arena, record_map); 190 } 191