summaryrefslogtreecommitdiff
path: root/makima/src/db/models.rs
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2026-01-26 20:19:30 +0000
committersoryu <soryu@soryu.co>2026-01-26 20:19:30 +0000
commit04e1e8f0dd85d19917ac5ba0b73cba65ebac8976 (patch)
treee52537dd2a33c10156f1378ffdc6803bc983482d /makima/src/db/models.rs
parent6328477bc459eca0243b685553dbd75b925fdc8a (diff)
downloadsoryu-04e1e8f0dd85d19917ac5ba0b73cba65ebac8976.tar.gz
soryu-04e1e8f0dd85d19917ac5ba0b73cba65ebac8976.zip
Add completion phases
Diffstat (limited to 'makima/src/db/models.rs')
-rw-r--r--makima/src/db/models.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/makima/src/db/models.rs b/makima/src/db/models.rs
index 0c1d9f2..95517a1 100644
--- a/makima/src/db/models.rs
+++ b/makima/src/db/models.rs
@@ -1321,6 +1321,11 @@ pub struct Contract {
/// phase outputs (like plans, requirements, etc.) before continuing.
#[serde(default)]
pub phase_guard: bool,
+ /// Completed deliverables per phase.
+ /// Structure: { "plan": ["plan-document"], "execute": ["pull-request"] }
+ #[sqlx(json)]
+ #[serde(default)]
+ pub completed_deliverables: serde_json::Value,
pub version: i32,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
@@ -1374,6 +1379,25 @@ impl Contract {
_ => ContractPhase::Execute, // simple and execute both end at execute
}
}
+
+ /// Get completed deliverable IDs for a specific phase
+ pub fn get_completed_deliverables(&self, phase: &str) -> Vec<String> {
+ self.completed_deliverables
+ .get(phase)
+ .and_then(|v| v.as_array())
+ .map(|arr| {
+ arr.iter()
+ .filter_map(|v| v.as_str().map(String::from))
+ .collect()
+ })
+ .unwrap_or_default()
+ }
+
+ /// Check if a specific deliverable is marked as complete for a phase
+ pub fn is_deliverable_complete(&self, phase: &str, deliverable_id: &str) -> bool {
+ self.get_completed_deliverables(phase)
+ .contains(&deliverable_id.to_string())
+ }
}
/// Contract repository record from the database