From 8e50447cd323e762eaec40fa8c3af507eef41a1b Mon Sep 17 00:00:00 2001 From: Jack Bates Date: Tue, 26 Jan 2021 11:20:51 -0700 Subject: [PATCH] Ignore draft PRs outside of the project board --- src/queries/all-open-prs-query.ts | 5 +++-- src/queries/schema/GetAllOpenPRsAndCardIDs.ts | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/queries/all-open-prs-query.ts b/src/queries/all-open-prs-query.ts index 49135b0a6..ce7dac5f2 100644 --- a/src/queries/all-open-prs-query.ts +++ b/src/queries/all-open-prs-query.ts @@ -9,6 +9,7 @@ query GetAllOpenPRsAndCardIDs($endCursor: String) { id pullRequests(states: OPEN, orderBy: { field: UPDATED_AT, direction: DESC }, first: 100, after: $endCursor) { nodes { + isDraft number projectCards(first: 100) { nodes { id } } } @@ -30,9 +31,9 @@ export async function getAllOpenPRsAndCardIDs() { fetchPolicy: "no-cache", variables: { endCursor } }); - prNumbers.push(...noNullish(result.data.repository?.pullRequests.nodes).map(pr => pr.number)); + prNumbers.push(...noNullish(result.data.repository?.pullRequests.nodes).filter(pr => !pr.isDraft).map(pr => pr.number)); for (const pr of noNullish(result.data.repository?.pullRequests.nodes)) { - cardIDs.push(...noNullish(pr.projectCards.nodes).map(card => card.id)); + if (!pr.isDraft) cardIDs.push(...noNullish(pr.projectCards.nodes).map(card => card.id)); } if (!result.data.repository?.pullRequests.pageInfo.hasNextPage) { return { prNumbers, cardIDs }; diff --git a/src/queries/schema/GetAllOpenPRsAndCardIDs.ts b/src/queries/schema/GetAllOpenPRsAndCardIDs.ts index 12306dcc5..0de859ec6 100644 --- a/src/queries/schema/GetAllOpenPRsAndCardIDs.ts +++ b/src/queries/schema/GetAllOpenPRsAndCardIDs.ts @@ -22,6 +22,10 @@ export interface GetAllOpenPRsAndCardIDs_repository_pullRequests_nodes_projectCa export interface GetAllOpenPRsAndCardIDs_repository_pullRequests_nodes { __typename: "PullRequest"; + /** + * Identifies if the pull request is a draft. + */ + isDraft: boolean; /** * Identifies the pull request number. */