refactor(integrations): IngestWatchEventDeps, scoped Arc deps, WatchEventCleanupJob
This commit is contained in:
@@ -1,12 +1,18 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use domain::{
|
||||
errors::DomainError,
|
||||
models::WatchEventStatus,
|
||||
ports::WatchEventRepository,
|
||||
value_objects::{UserId, WatchEventId},
|
||||
};
|
||||
|
||||
use crate::{context::AppContext, integrations::commands::DismissWatchEventsCommand};
|
||||
use crate::integrations::commands::DismissWatchEventsCommand;
|
||||
|
||||
pub async fn execute(ctx: &AppContext, cmd: DismissWatchEventsCommand) -> Result<u32, DomainError> {
|
||||
pub async fn execute(
|
||||
watch_event: Arc<dyn WatchEventRepository>,
|
||||
cmd: DismissWatchEventsCommand,
|
||||
) -> Result<u32, DomainError> {
|
||||
let user_id = UserId::from_uuid(cmd.user_id);
|
||||
if cmd.event_ids.is_empty() {
|
||||
return Ok(0);
|
||||
@@ -18,7 +24,7 @@ pub async fn execute(ctx: &AppContext, cmd: DismissWatchEventsCommand) -> Result
|
||||
.map(|id| WatchEventId::from_uuid(*id))
|
||||
.collect();
|
||||
|
||||
let events = ctx.repos.watch_event.get_by_ids(&ids).await?;
|
||||
let events = watch_event.get_by_ids(&ids).await?;
|
||||
|
||||
if events.len() != ids.len() {
|
||||
return Err(DomainError::NotFound(
|
||||
@@ -31,9 +37,7 @@ pub async fn execute(ctx: &AppContext, cmd: DismissWatchEventsCommand) -> Result
|
||||
}
|
||||
}
|
||||
|
||||
let count = ctx
|
||||
.repos
|
||||
.watch_event
|
||||
let count = watch_event
|
||||
.update_status_batch(&ids, WatchEventStatus::Dismissed)
|
||||
.await?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user