use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BatchJob {
pub id: String,
pub workflow_id: String,
pub items: Vec<BatchItem>,
pub concurrency: usize,
pub checkpoint_every: usize,
pub status: BatchStatus,
pub created_at: DateTime<Utc>,
pub started_at: Option<DateTime<Utc>>,
pub completed_at: Option<DateTime<Utc>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BatchItem {
pub index: usize,
pub input: serde_json::Value,
pub status: BatchItemStatus,
pub output: Option<serde_json::Value>,
pub error: Option<String>,
pub duration_ms: Option<u64>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum BatchStatus {
Pending,
Running,
Paused,
Completed,
PartiallyCompleted,
Failed,
Cancelled,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum BatchItemStatus {
Pending,
Running,
Success,
Failed,
Skipped,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BatchProgress {
pub batch_id: String,
pub total_items: usize,
pub completed: usize,
pub failed: usize,
pub skipped: usize,
pub running: usize,
pub pending: usize,
pub percent_complete: f64,
pub estimated_remaining_ms: Option<u64>,
pub last_checkpoint_index: Option<usize>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BatchReport {
pub batch_id: String,
pub total_items: usize,
pub success_count: usize,
pub fail_count: usize,
pub skip_count: usize,
pub total_duration_ms: u64,
pub avg_item_duration_ms: f64,
pub error_summary: Vec<BatchErrorGroup>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BatchErrorGroup {
pub error_pattern: String,
pub count: usize,
pub sample_indices: Vec<usize>,
}