Skip to main content

agentics_domain/models/challenge_creation/
lifecycle.rs

1//! Challenge review record lifecycle values.
2
3use serde::{Deserialize, Serialize};
4
5/// Status used by the challenge review record lifecycle.
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, schemars::JsonSchema)]
7#[serde(rename_all = "snake_case")]
8pub enum ChallengeReviewRecordStatus {
9    PendingReview,
10    Validated,
11    Approved,
12    Publishing,
13    Rejected,
14    Published,
15    Abandoned,
16}
17
18impl ChallengeReviewRecordStatus {
19    /// Stable database string for this review record status.
20    pub fn as_str(self) -> &'static str {
21        match self {
22            Self::PendingReview => "pending_review",
23            Self::Validated => "validated",
24            Self::Approved => "approved",
25            Self::Publishing => "publishing",
26            Self::Rejected => "rejected",
27            Self::Published => "published",
28            Self::Abandoned => "abandoned",
29        }
30    }
31
32    /// Parse a stable database string for this review record status.
33    pub fn from_storage_value(value: &str) -> Option<Self> {
34        match value {
35            "pending_review" => Some(Self::PendingReview),
36            "validated" => Some(Self::Validated),
37            "approved" => Some(Self::Approved),
38            "publishing" => Some(Self::Publishing),
39            "rejected" => Some(Self::Rejected),
40            "published" => Some(Self::Published),
41            "abandoned" => Some(Self::Abandoned),
42            _ => None,
43        }
44    }
45}
46
47/// Validation record status for a challenge review record.
48#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, schemars::JsonSchema)]
49#[serde(rename_all = "snake_case")]
50pub enum ChallengeReviewValidationStatus {
51    Running,
52    Passed,
53    Failed,
54}
55
56impl ChallengeReviewValidationStatus {
57    /// Stable database string for this validation outcome.
58    pub fn as_str(self) -> &'static str {
59        match self {
60            Self::Running => "running",
61            Self::Passed => "passed",
62            Self::Failed => "failed",
63        }
64    }
65
66    /// Parse a stable database string for this validation outcome.
67    pub fn from_storage_value(value: &str) -> Option<Self> {
68        match value {
69            "running" => Some(Self::Running),
70            "passed" => Some(Self::Passed),
71            "failed" => Some(Self::Failed),
72            _ => None,
73        }
74    }
75}