registry: type metadata and yaml import timestamps

This commit is contained in:
a.tolmachev
2026-04-19 07:36:35 +00:00
parent 179165838a
commit 153f9cb108
7 changed files with 43 additions and 34 deletions
+6 -6
View File
@@ -920,7 +920,7 @@ fn build_sample_metadata(
storage_ref: String,
content_type: String,
file_name: Option<String>,
created_at: String,
created_at: OffsetDateTime,
) -> Result<OperationSampleMetadata, RegistryError> {
Ok(OperationSampleMetadata {
id: crank_core::SampleId::new(id),
@@ -943,7 +943,7 @@ fn build_descriptor_metadata(
storage_ref: String,
source_name: Option<String>,
package_index: Option<Value>,
created_at: String,
created_at: OffsetDateTime,
) -> Result<DescriptorMetadata, RegistryError> {
Ok(DescriptorMetadata {
id: crank_core::DescriptorId::new(id),
@@ -1335,7 +1335,7 @@ mod tests {
storage_ref: "file:///tmp/input.json".to_owned(),
content_type: "application/json".to_owned(),
file_name: Some("input.json".to_owned()),
created_at: "2026-03-25T12:01:00Z".to_owned(),
created_at: timestamp("2026-03-25T12:01:00Z"),
};
let descriptor = DescriptorMetadata {
id: "descriptor_01".into(),
@@ -1345,7 +1345,7 @@ mod tests {
storage_ref: "file:///tmp/schema.desc".to_owned(),
source_name: Some("schema.desc".to_owned()),
package_index: Some(json!({ "crm.v1": ["LeadService"] })),
created_at: "2026-03-25T12:02:00Z".to_owned(),
created_at: timestamp("2026-03-25T12:02:00Z"),
};
registry
@@ -1436,7 +1436,7 @@ mod tests {
source_sample_id: None,
format_version: "v1",
mode: ExportMode::Portable,
created_at: "2026-03-25T12:00:00Z",
created_at: &timestamp("2026-03-25T12:00:00Z"),
})
.await
.unwrap();
@@ -1449,7 +1449,7 @@ mod tests {
result_operation_id: Some(operation.id.clone()),
result_version: Some(2),
error_text: None,
finished_at: "2026-03-25T12:05:00Z".to_owned(),
finished_at: timestamp("2026-03-25T12:05:00Z"),
},
)
.await
@@ -854,7 +854,7 @@ impl PostgresRegistry {
.bind(&request.sample.storage_ref)
.bind(&request.sample.content_type)
.bind(request.sample.file_name.as_deref())
.bind(&request.sample.created_at)
.bind(request.sample.created_at)
.execute(&self.pool)
.await?;
@@ -875,7 +875,7 @@ impl PostgresRegistry {
storage_ref,
content_type,
file_name,
to_char(created_at at time zone 'UTC', 'YYYY-MM-DD\"T\"HH24:MI:SS\"Z\"') as \"created_at!\"
created_at as \"created_at!: time::OffsetDateTime\"
from operation_samples
where operation_id = $1 and version = $2
order by created_at asc",
@@ -941,7 +941,7 @@ impl PostgresRegistry {
.bind(&request.descriptor.storage_ref)
.bind(request.descriptor.source_name.as_deref())
.bind(serialize_option_json_value(&request.descriptor.package_index)?.map(Json))
.bind(&request.descriptor.created_at)
.bind(request.descriptor.created_at)
.execute(&self.pool)
.await?;
@@ -962,7 +962,7 @@ impl PostgresRegistry {
storage_ref,
source_name,
package_index_json,
to_char(created_at at time zone 'UTC', 'YYYY-MM-DD\"T\"HH24:MI:SS\"Z\"') as \"created_at!\"
created_at as \"created_at!: time::OffsetDateTime\"
from descriptors
where operation_id = $1 and version = $2
order by created_at asc",
@@ -60,7 +60,7 @@ impl PostgresRegistry {
)
.bind(completion.result_version.map(to_db_version))
.bind(completion.error_text.as_deref())
.bind(&completion.finished_at)
.bind(completion.finished_at)
.execute(&self.pool)
.await?;
@@ -87,8 +87,8 @@ impl PostgresRegistry {
result_operation_id,
result_version,
error_text,
to_char(created_at at time zone 'UTC', 'YYYY-MM-DD\"T\"HH24:MI:SS\"Z\"') as created_at,
to_char(finished_at at time zone 'UTC', 'YYYY-MM-DD\"T\"HH24:MI:SS\"Z\"') as finished_at
created_at,
finished_at
from yaml_import_jobs
where id = $1",
)