(
&self,
path: &str,
entry: &VaultEntry,
)
| 263 | } |
| 264 | |
| 265 | pub(super) fn extract( |
| 266 | &self, |
| 267 | path: &str, |
| 268 | entry: &VaultEntry, |
| 269 | ) -> Result<KgSubgraph, RepositoryError> { |
| 270 | if entry.entry_type == VaultEntryType::Attestation { |
| 271 | return self.extract_signed_document(path, entry); |
| 272 | } |
| 273 | let mut graph = KgSubgraph::default(); |
| 274 | let Some(subject) = self.paths.get(path) else { |
| 275 | if entry.entry_type == VaultEntryType::Intent { |
| 276 | let project = iri::mint_project(&self.project); |
| 277 | graph.nodes.push(KgNode::new( |
| 278 | &project, |
| 279 | C::Project, |
| 280 | self.project.to_base32(), |
| 281 | "vcs", |
| 282 | )); |
| 283 | self.finding( |
| 284 | &mut graph, |
| 285 | &project, |
| 286 | "MissingIntentId", |
| 287 | &format!("Intent has no canonical ULID: {path}"), |
| 288 | path, |
| 289 | ); |
| 290 | } |
| 291 | return Ok(graph); |
| 292 | }; |
| 293 | let fm: serde_json::Value = |
| 294 | serde_json::from_str(&entry.frontmatter_json).unwrap_or_default(); |
| 295 | let class = self.subjects.get(subject).expect("indexed subject").1; |
| 296 | let label = fm |
| 297 | .get("title") |
| 298 | .or_else(|| fm.get("name")) |
| 299 | .and_then(|v| v.as_str()) |
| 300 | .unwrap_or(path); |
| 301 | let mut node = KgNode::new(subject, class, label, "vault") |
| 302 | .with_metadata(serde_json::json!({"vault_path": path, "derived_from_vault_path": path, "created_at": entry.created_at, "updated_at": entry.updated_at, |
| 303 | "status": fm.get("status"), "priority": fm.get("priority"), "human_key": fm.get("id"), "uid": fm.get("uid")})); |
| 304 | if let Some(description) = fm |
| 305 | .get("description") |
| 306 | .or_else(|| fm.get("title")) |
| 307 | .and_then(|v| v.as_str()) |
| 308 | { |
| 309 | node = node.with_summary(description); |
| 310 | } |
| 311 | if class == C::WorkIntent { |
| 312 | match fm.get("kind").and_then(|v| v.as_str()).unwrap_or("feature") { |
| 313 | "feature" => node = node.with_type(C::FeatureIntent), |
| 314 | "bug" => node = node.with_type(C::BugIntent), |
| 315 | "review" => node = node.with_type(C::ReviewIntent), |
| 316 | _ => {} |
| 317 | } |
| 318 | if matches!( |
| 319 | fm.get("status").and_then(|v| v.as_str()), |
| 320 | Some("in_progress" | "needs-review" | "done") |
| 321 | ) { |
| 322 | node = node.with_type(C::ManagedIntent); |
no test coverage detected