feat: wrapup date validation, delete endpoint, failed record cleanup
Some checks failed
CI / Check / Test (push) Failing after 41s

This commit is contained in:
2026-06-03 00:54:08 +02:00
parent 3f483f8f81
commit 241063c914
13 changed files with 194 additions and 7 deletions

View File

@@ -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 ─────────────────────────────────────────────────

View File

@@ -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")
}
}