Skip to content

Commit b1509c5

Browse files
authored
Merge pull request #246 from Sakib25800/fix/add-pr-base-branch-index
Add PR repo status column database index
2 parents 680a300 + 7653354 commit b1509c5

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

.sqlx/query-3d4594e3ae0a433d15d3642d2e0af16c400ec665e610c9f5a9db5450d5f5bed7.json renamed to .sqlx/query-8df7a6cde441de1149c79aced1a596be30e273fef7f63bda3be4284ee600bf5c.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- Add down migration script here
2+
DROP INDEX IF EXISTS pull_request_status_idx;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- Add up migration script here
2+
CREATE INDEX IF NOT EXISTS pull_request_status_idx ON pull_request (status);

src/database/operations.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,6 @@ pub(crate) async fn upsert_pull_request(
163163
.await
164164
}
165165

166-
// FIXME:
167-
// 1) Add a database index on (repository, base_branch)
168-
// 2) Filter PRs by state (only update open PRs, once we have PR state tracking)
169166
pub(crate) async fn update_mergeable_states_by_base_branch(
170167
executor: impl PgExecutor<'_>,
171168
repo: &GithubRepoName,
@@ -177,7 +174,9 @@ pub(crate) async fn update_mergeable_states_by_base_branch(
177174
r#"
178175
UPDATE pull_request
179176
SET mergeable_state = $1
180-
WHERE repository = $2 AND base_branch = $3
177+
WHERE repository = $2
178+
AND base_branch = $3
179+
AND status IN ('open', 'draft')
181180
"#,
182181
mergeable_state as _,
183182
repo as &GithubRepoName,

0 commit comments

Comments
 (0)