fix: treat empty pull state as open for Tangled MRs
Author: Aaron Steven White
Commit
a463c87e34e477aa6d284384a165407d841f5460Parent: 3891442a28
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 +58 -25
@@ -96,38 +96,71 @@ pub async fn list_for_repo(
9696 limit: i64, 9797 cursor: Option<&str>, 9898 ) -> Result<Vec<PullRow>, sqlx::Error> { 99+ // Tangled pulls have state='' since state is tracked via separate records. 100+ // Treat 'open' filter as matching '' or 'open' or NULL. 99101 match (state_filter, cursor) { 100102 (Some(state), Some(cursor_ts)) => { 101103 let ts: DateTime<Utc> = cursor_ts 102104 .parse() 103105 .map_err(|_| sqlx::Error::Protocol("invalid cursor".into()))?; 104- sqlx::query_as::<_, PullRow>( 105- "SELECT did, rkey, repo_did, repo_name, title, body, target_ref, source_ref, \ 106- source_repo, state, comment_count, created_at, indexed_at \ 107- FROM pulls WHERE repo_did = $1 AND repo_name = $2 AND state = $3 AND created_at < $4 \ 108- ORDER BY created_at DESC LIMIT $5", 109- ) 110- .bind(repo_did) 111- .bind(repo_name) 112- .bind(state) 113- .bind(ts) 114- .bind(limit) 115- .fetch_all(pool) 116- .await 106+ if state == "open" { 107+ sqlx::query_as::<_, PullRow>( 108+ "SELECT did, rkey, repo_did, repo_name, title, body, target_ref, source_ref, \ 109+ source_repo, state, comment_count, created_at, indexed_at \ 110+ FROM pulls WHERE repo_did = $1 AND repo_name = $2 \ 111+ AND (state = '' OR state = 'open' OR state IS NULL) AND created_at < $3 \ 112+ ORDER BY created_at DESC LIMIT $4", 113+ ) 114+ .bind(repo_did) 115+ .bind(repo_name) 116+ .bind(ts) 117+ .bind(limit) 118+ .fetch_all(pool) 119+ .await 120+ } else { 121+ sqlx::query_as::<_, PullRow>( 122+ "SELECT did, rkey, repo_did, repo_name, title, body, target_ref, source_ref, \ 123+ source_repo, state, comment_count, created_at, indexed_at \ 124+ FROM pulls WHERE repo_did = $1 AND repo_name = $2 AND state = $3 AND created_at < $4 \ 125+ ORDER BY created_at DESC LIMIT $5", 126+ ) 127+ .bind(repo_did) 128+ .bind(repo_name) 129+ .bind(state) 130+ .bind(ts) 131+ .bind(limit) 132+ .fetch_all(pool) 133+ .await 134+ } 117135 } 118136 (Some(state), None) => { 119- sqlx::query_as::<_, PullRow>( 120- "SELECT did, rkey, repo_did, repo_name, title, body, target_ref, source_ref, \ 121- source_repo, state, comment_count, created_at, indexed_at \ 122- FROM pulls WHERE repo_did = $1 AND repo_name = $2 AND state = $3 \ 123- ORDER BY created_at DESC LIMIT $4", 124- ) 125- .bind(repo_did) 126- .bind(repo_name) 127- .bind(state) 128- .bind(limit) 129- .fetch_all(pool) 130- .await 137+ if state == "open" { 138+ sqlx::query_as::<_, PullRow>( 139+ "SELECT did, rkey, repo_did, repo_name, title, body, target_ref, source_ref, \ 140+ source_repo, state, comment_count, created_at, indexed_at \ 141+ FROM pulls WHERE repo_did = $1 AND repo_name = $2 \ 142+ AND (state = '' OR state = 'open' OR state IS NULL) \ 143+ ORDER BY created_at DESC LIMIT $3", 144+ ) 145+ .bind(repo_did) 146+ .bind(repo_name) 147+ .bind(limit) 148+ .fetch_all(pool) 149+ .await 150+ } else { 151+ sqlx::query_as::<_, PullRow>( 152+ "SELECT did, rkey, repo_did, repo_name, title, body, target_ref, source_ref, \ 153+ source_repo, state, comment_count, created_at, indexed_at \ 154+ FROM pulls WHERE repo_did = $1 AND repo_name = $2 AND state = $3 \ 155+ ORDER BY created_at DESC LIMIT $4", 156+ ) 157+ .bind(repo_did) 158+ .bind(repo_name) 159+ .bind(state) 160+ .bind(limit) 161+ .fetch_all(pool) 162+ .await 163+ } 131164 } 132165 (None, Some(cursor_ts)) => { 133166 let ts: DateTime<Utc> = cursor_ts