feat: wrapup date validation, delete endpoint, failed record cleanup
Some checks failed
CI / Check / Test (push) Failing after 41s
Some checks failed
CI / Check / Test (push) Failing after 41s
This commit is contained in:
@@ -495,6 +495,11 @@ pub trait WrapUpRepository: Send + Sync {
|
||||
start: NaiveDate,
|
||||
end: NaiveDate,
|
||||
) -> Result<Option<WrapUpRecord>, DomainError>;
|
||||
async fn delete(&self, id: &WrapUpId) -> Result<(), DomainError>;
|
||||
async fn delete_failed_older_than(
|
||||
&self,
|
||||
before: chrono::NaiveDateTime,
|
||||
) -> Result<u64, DomainError>;
|
||||
}
|
||||
|
||||
// ── Wrap-up / Year-in-Review ─────────────────────────────────────────────────
|
||||
|
||||
@@ -1152,6 +1152,24 @@ impl WrapUpRepository for InMemoryWrapUpRepository {
|
||||
.find(|r| r.user_id == user_id && r.start_date == start && r.end_date == end)
|
||||
.cloned())
|
||||
}
|
||||
|
||||
async fn delete(&self, id: &WrapUpId) -> Result<(), DomainError> {
|
||||
let mut store = self.store.lock().unwrap();
|
||||
store.retain(|r| r.id != *id);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn delete_failed_older_than(
|
||||
&self,
|
||||
before: chrono::NaiveDateTime,
|
||||
) -> Result<u64, DomainError> {
|
||||
let mut store = self.store.lock().unwrap();
|
||||
let before_len = store.len();
|
||||
store.retain(|r| {
|
||||
!(r.status == crate::models::wrapup::WrapUpStatus::Failed && r.created_at < before)
|
||||
});
|
||||
Ok((before_len - store.len()) as u64)
|
||||
}
|
||||
}
|
||||
|
||||
// ── PanicWrapUpRepository ──────────────────────────────────────────────────
|
||||
@@ -1197,4 +1215,13 @@ impl WrapUpRepository for PanicWrapUpRepository {
|
||||
) -> Result<Option<crate::models::wrapup::WrapUpRecord>, DomainError> {
|
||||
panic!("PanicWrapUpRepository called")
|
||||
}
|
||||
async fn delete(&self, _: &WrapUpId) -> Result<(), DomainError> {
|
||||
panic!("PanicWrapUpRepository called")
|
||||
}
|
||||
async fn delete_failed_older_than(
|
||||
&self,
|
||||
_: chrono::NaiveDateTime,
|
||||
) -> Result<u64, DomainError> {
|
||||
panic!("PanicWrapUpRepository called")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user