Skip to content

Commit 1b88a71

Browse files
committed
refactor: api
1 parent fe61bc1 commit 1b88a71

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/branchProtection.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export async function getBranchProtectionRules(
1212
await ctx.octokit.graphql(
1313
`query ($owner: String!, $repo: String!) {
1414
repository(name: $repo, owner: $owner) {
15-
branchProtectionRules(first: 10) {
15+
branchProtectionRules(first: ${branchProtectionRuleCount}) {
1616
nodes {
1717
requiredApprovingReviewCount
1818
requiredStatusCheckContexts
@@ -32,3 +32,5 @@ export async function getBranchProtectionRules(
3232
: v.pattern === 'main' || v.pattern === 'master'
3333
)
3434
}
35+
36+
const branchProtectionRuleCount = 10

src/pullRequest.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ import {
66
RepositoryListPullRequest
77
} from './type'
88

9-
const firstPrNum = 50
10-
const checksNum = 50
11-
const labelNum = 10
12-
139
export async function getPullRequest(
1410
ctx: GhContext,
1511
num: number
@@ -100,7 +96,7 @@ async function listPullRequests(ctx: GhContext): Promise<PullRequestInfo[]> {
10096
const result: RepositoryListPullRequest = await ctx.octokit.graphql(
10197
`query ($owner: String!, $repo: String!) {
10298
repository(name: $repo, owner: $owner) {
103-
pullRequests(first: ${firstPrNum}, states: OPEN) {
99+
pullRequests(first: ${pullRequestCount}, states: OPEN) {
104100
nodes {
105101
${pullRequestFragment}
106102
}
@@ -118,6 +114,10 @@ async function listPullRequests(ctx: GhContext): Promise<PullRequestInfo[]> {
118114
return result.repository.pullRequests.nodes
119115
}
120116

117+
const pullRequestCount = 50
118+
const checkCount = 50
119+
const labelCount = 10
120+
121121
const pullRequestFragment = `
122122
id
123123
title
@@ -132,7 +132,7 @@ const pullRequestFragment = `
132132
reviewRequests {
133133
totalCount
134134
}
135-
labels(first: ${labelNum}) {
135+
labels(first: ${labelCount}) {
136136
nodes {
137137
name
138138
}
@@ -141,7 +141,7 @@ const pullRequestFragment = `
141141
nodes {
142142
commit {
143143
statusCheckRollup {
144-
contexts(first: ${checksNum}) {
144+
contexts(first: ${checkCount}) {
145145
nodes {
146146
... on CheckRun {
147147
name

0 commit comments

Comments
 (0)