registry: type metadata and yaml import timestamps
This commit is contained in:
@@ -261,7 +261,8 @@ pub struct OperationSampleMetadata {
|
||||
pub storage_ref: String,
|
||||
pub content_type: String,
|
||||
pub file_name: Option<String>,
|
||||
pub created_at: String,
|
||||
#[serde(with = "time::serde::rfc3339")]
|
||||
pub created_at: OffsetDateTime,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
@@ -283,7 +284,8 @@ pub struct DescriptorMetadata {
|
||||
pub storage_ref: String,
|
||||
pub source_name: Option<String>,
|
||||
pub package_index: Option<Value>,
|
||||
pub created_at: String,
|
||||
#[serde(with = "time::serde::rfc3339")]
|
||||
pub created_at: OffsetDateTime,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
@@ -304,8 +306,10 @@ pub struct YamlImportJob {
|
||||
pub result_operation_id: Option<OperationId>,
|
||||
pub result_version: Option<u32>,
|
||||
pub error_text: Option<String>,
|
||||
pub created_at: String,
|
||||
pub finished_at: Option<String>,
|
||||
#[serde(with = "time::serde::rfc3339")]
|
||||
pub created_at: OffsetDateTime,
|
||||
#[serde(with = "time::serde::rfc3339::option")]
|
||||
pub finished_at: Option<OffsetDateTime>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
@@ -314,7 +318,8 @@ pub struct YamlImportJobCompletion {
|
||||
pub result_operation_id: Option<OperationId>,
|
||||
pub result_version: Option<u32>,
|
||||
pub error_text: Option<String>,
|
||||
pub finished_at: String,
|
||||
#[serde(with = "time::serde::rfc3339")]
|
||||
pub finished_at: OffsetDateTime,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
@@ -380,7 +385,7 @@ pub struct CreateYamlImportJobRequest<'a> {
|
||||
pub source_sample_id: Option<&'a SampleId>,
|
||||
pub format_version: &'a str,
|
||||
pub mode: ExportMode,
|
||||
pub created_at: &'a str,
|
||||
pub created_at: &'a OffsetDateTime,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
|
||||
@@ -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: ×tamp("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",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user