refactor: store typed WrapUpReport in domain, serialize in adapters
Some checks failed
CI / Check / Test (push) Failing after 45s
Some checks failed
CI / Check / Test (push) Failing after 45s
This commit is contained in:
@@ -160,7 +160,7 @@ pub struct WrapUpRecord {
|
||||
pub start_date: NaiveDate,
|
||||
pub end_date: NaiveDate,
|
||||
pub status: WrapUpStatus,
|
||||
pub report_json: Option<String>,
|
||||
pub report: Option<WrapUpReport>,
|
||||
pub error_message: Option<String>,
|
||||
pub created_at: NaiveDateTime,
|
||||
pub completed_at: Option<NaiveDateTime>,
|
||||
|
||||
@@ -485,7 +485,7 @@ pub trait WrapUpRepository: Send + Sync {
|
||||
status: &WrapUpStatus,
|
||||
error: Option<&str>,
|
||||
) -> Result<(), DomainError>;
|
||||
async fn set_complete(&self, id: &WrapUpId, report_json: &str) -> Result<(), DomainError>;
|
||||
async fn set_complete(&self, id: &WrapUpId, report: &WrapUpReport) -> Result<(), DomainError>;
|
||||
async fn get_by_id(&self, id: &WrapUpId) -> Result<Option<WrapUpRecord>, DomainError>;
|
||||
async fn list_for_user(&self, user_id: Uuid) -> Result<Vec<WrapUpRecord>, DomainError>;
|
||||
async fn list_global(&self) -> Result<Vec<WrapUpRecord>, DomainError>;
|
||||
|
||||
@@ -1099,11 +1099,11 @@ impl WrapUpRepository for InMemoryWrapUpRepository {
|
||||
}
|
||||
}
|
||||
|
||||
async fn set_complete(&self, id: &WrapUpId, report_json: &str) -> Result<(), DomainError> {
|
||||
async fn set_complete(&self, id: &WrapUpId, report: &crate::models::wrapup::WrapUpReport) -> Result<(), DomainError> {
|
||||
let mut store = self.store.lock().unwrap();
|
||||
if let Some(rec) = store.iter_mut().find(|r| r.id == *id) {
|
||||
rec.status = crate::models::wrapup::WrapUpStatus::Ready;
|
||||
rec.report_json = Some(report_json.to_string());
|
||||
rec.report = Some(report.clone());
|
||||
rec.completed_at = Some(chrono::Utc::now().naive_utc());
|
||||
Ok(())
|
||||
} else {
|
||||
@@ -1189,7 +1189,7 @@ impl WrapUpRepository for PanicWrapUpRepository {
|
||||
) -> Result<(), DomainError> {
|
||||
panic!("PanicWrapUpRepository called")
|
||||
}
|
||||
async fn set_complete(&self, _: &WrapUpId, _: &str) -> Result<(), DomainError> {
|
||||
async fn set_complete(&self, _: &WrapUpId, _: &crate::models::wrapup::WrapUpReport) -> Result<(), DomainError> {
|
||||
panic!("PanicWrapUpRepository called")
|
||||
}
|
||||
async fn get_by_id(
|
||||
|
||||
Reference in New Issue
Block a user