Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
1.9 kB · 62 lines
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263import albedo_sqliteimport gleam/dynamic/decodeimport gleam/option.{type Option}import sqlight
/// Shared return type for queries in this directory:/// src/albedo_ext_artifacts/versions/sql/history.sql/// src/albedo_ext_artifacts/versions/sql/version.sqlpub type VersionRow { VersionRow( version: Int, entry: String, manifest: String, cell: Option(String), created_at: Int, bytes: Int, )}
fn version_row_decoder() -> decode.Decoder(VersionRow) { use version <- decode.field(0, decode.int) use entry <- decode.field(1, decode.string) use manifest <- decode.field(2, decode.string) use cell <- decode.field(3, decode.optional(decode.string)) use created_at <- decode.field(4, decode.int) use bytes <- decode.field(5, decode.int) decode.success(VersionRow( version:, entry:, manifest:, cell:, created_at:, bytes:, ))}
/// Generated from src/albedo_ext_artifacts/versions/sql/history.sqlpub fn history( db db: sqlight.Connection, id id: String,) -> Result(List(VersionRow), String) { albedo_sqlite.rows( "SELECT v.version,v.entry,v.manifest,v.cell,v.created_at,v.bytes FROM artifact_versions v WHERE v.artifact=@id ORDER BY v.version DESC", on: db, with: [sqlight.text(id)], expecting: version_row_decoder(), )}
/// Generated from src/albedo_ext_artifacts/versions/sql/version.sqlpub fn version( db db: sqlight.Connection, id id: String, version version: Option(Int),) -> Result(List(VersionRow), String) { albedo_sqlite.rows( "SELECT v.version,v.entry,v.manifest,v.cell,v.created_at,v.bytes FROM artifact_versions v JOIN artifacts a ON a.id=v.artifact WHERE v.artifact=@id AND v.version=COALESCE(@version,a.version)", on: db, with: [sqlight.text(id), sqlight.nullable(sqlight.int, version)], expecting: version_row_decoder(), )}