| 158 | } |
| 159 | |
| 160 | fn intents(txn: &redb::ReadTransaction) -> Observation<IntentCounts> { |
| 161 | let result = (|| { |
| 162 | let table = txn.open_table(VAULT_MANIFEST).ok()?; |
| 163 | let value = table.get("manifest").ok()??; |
| 164 | let manifest: VaultManifest = serde_json::from_slice(value.value()).ok()?; |
| 165 | let mut counts = IntentCounts::default(); |
| 166 | for intent in manifest.intents.values() { |
| 167 | counts.total += 1; |
| 168 | match intent.status.as_str() { |
| 169 | "backlog" => counts.backlog += 1, |
| 170 | "planned" => counts.planned += 1, |
| 171 | "in_progress" => counts.in_progress += 1, |
| 172 | "needs-review" => counts.needs_review += 1, |
| 173 | "done" => counts.done += 1, |
| 174 | "icebox" => counts.icebox += 1, |
| 175 | _ => counts.other += 1, |
| 176 | } |
| 177 | } |
| 178 | Some(counts) |
| 179 | })(); |
| 180 | match result { |
| 181 | Some(value) => Observation::available(value), |
| 182 | None => Observation::unavailable("vault manifest unavailable or unreadable"), |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | pub(crate) fn collect(workspace: &Result<Option<PathBuf>, SourceError>) -> RepositoryMetrics { |
| 187 | let root = match workspace { |