fix: map Tangled pull.status to state, treat empty state as open
Author: Aaron Steven White
Commit
625db4d006cabea851b448e614ad1121221d3b07Parent: a463c87e34
Structural diff unavailable
These commits were pushed via plain git push, so no pre-parsed
schemas are available. Install git-remote-cospan and re-push via panproto:// to
see scope-level changes, breaking change detection, and semantic diffs.
brew install panproto/tap/git-remote-cospan1 file changed +11 -2
@@ -305,19 +305,28 @@ async fn dispatch_special_upsert(
305305 row.did = did.to_string(); 306306 row.rkey = rkey.to_string(); 307307 row.indexed_at = Utc::now(); 308+ // Tangled uses "status" not "state"; fill from raw record if empty 309+ if row.state.is_empty() { 310+ row.state = rec.get("status").and_then(|v| v.as_str()).unwrap_or("").to_string(); 311+ } 312+ if row.pull_uri.is_empty() { 313+ row.pull_uri = pull_uri.clone(); 314+ } 308315 let new_state = row.state.clone(); 309316 db::pull_state::upsert(&state.db, &row).await?; 310317 311318 let (pull_did, pull_rkey) = at_uri::parse_did_rkey(&pull_uri); 312319 if let Some(pull) = db::pull::get_by_pk(&state.db, &pull_did, &pull_rkey).await? { 313320 let old_state = &pull.state; 321+ let old_is_open = old_state.is_empty() || old_state == "open"; 322+ let new_is_open = new_state.is_empty() || new_state == "open"; 314323 if old_state != &new_state { 315324 db::pull::update_state(&state.db, &pull_did, &pull_rkey, &new_state).await?; 316325 317- if old_state == "open" && new_state != "open" { 326+ if old_is_open && !new_is_open { 318327 decrement_repo_open_mr_count(&state.db, &pull.repo_did, &pull.repo_name) 319328 .await?; 320- } else if old_state != "open" && new_state == "open" { 329+ } else if !old_is_open && new_is_open { 321330 increment_repo_open_mr_count(&state.db, &pull.repo_did, &pull.repo_name) 322331 .await?; 323332 }