app: add sidecar sync commands (export, detect, import, resolve, full export/import)
This commit is contained in:
1
crates/application/src/processing/queries/mod.rs
Normal file
1
crates/application/src/processing/queries/mod.rs
Normal file
@@ -0,0 +1 @@
|
||||
pub mod report_batch_progress;
|
||||
@@ -0,0 +1,36 @@
|
||||
use std::sync::Arc;
|
||||
use domain::{
|
||||
entities::{Job, JobBatch},
|
||||
errors::DomainError,
|
||||
ports::{JobBatchRepository, JobRepository},
|
||||
value_objects::SystemId,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub struct ReportBatchProgressQuery {
|
||||
pub batch_id: SystemId,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct BatchProgress {
|
||||
pub batch: JobBatch,
|
||||
pub jobs: Vec<Job>,
|
||||
}
|
||||
|
||||
pub struct ReportBatchProgressHandler {
|
||||
batch_repo: Arc<dyn JobBatchRepository>,
|
||||
job_repo: Arc<dyn JobRepository>,
|
||||
}
|
||||
|
||||
impl ReportBatchProgressHandler {
|
||||
pub fn new(batch_repo: Arc<dyn JobBatchRepository>, job_repo: Arc<dyn JobRepository>) -> Self {
|
||||
Self { batch_repo, job_repo }
|
||||
}
|
||||
|
||||
pub async fn execute(&self, query: ReportBatchProgressQuery) -> Result<BatchProgress, DomainError> {
|
||||
let batch = self.batch_repo.find_by_id(&query.batch_id).await?
|
||||
.ok_or_else(|| DomainError::NotFound(format!("Batch {} not found", query.batch_id)))?;
|
||||
let jobs = self.job_repo.find_by_batch(&query.batch_id).await?;
|
||||
Ok(BatchProgress { batch, jobs })
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user