mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
c021e94fce
Introduces a new http trigger in the Dashboard functions that returns all Pull Requests with merge conflicts. This allows us to show a list of PRs with merge conflicts in the dashboard. To ensure that the API calls are as fast as possible, the pull requests with conflicts are queried using Github's new GraphQL API.
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import {githubApiV4} from './github-api';
|
|
|
|
/** GraphQL query that finds all Pull Requests and their mergeable state. */
|
|
const getOpenPullRequestsWithMergeableStateQuery = `
|
|
query getOpenPullRequestsWithMergeableState($lastCursor: String) {
|
|
repository(owner: "angular", name: "material2") {
|
|
pullRequests(states: OPEN, first: 100, after: $lastCursor) {
|
|
pageInfo {
|
|
hasNextPage,
|
|
endCursor
|
|
}
|
|
nodes {
|
|
number,
|
|
mergeable
|
|
}
|
|
}
|
|
}
|
|
}`;
|
|
|
|
/** Pull Request node that will be returned by the Github V4 API. */
|
|
export interface PullRequestWithMergeableState {
|
|
number: number;
|
|
mergeable: string;
|
|
}
|
|
|
|
/** Queries the GitHub API to find all open pull requests and their mergeable state. */
|
|
export async function getOpenPullRequestsWithMergeableState()
|
|
: Promise<PullRequestWithMergeableState[]> {
|
|
const nodes: PullRequestWithMergeableState[] = [];
|
|
let lastData: any|null = null;
|
|
|
|
while (!lastData || lastData.repository.pullRequests.pageInfo.hasNextPage) {
|
|
lastData = await githubApiV4.request(getOpenPullRequestsWithMergeableStateQuery, {
|
|
lastCursor: lastData && lastData.repository.pullRequests.pageInfo.endCursor
|
|
});
|
|
|
|
nodes.push(...lastData.repository.pullRequests.nodes);
|
|
}
|
|
|
|
return nodes;
|
|
}
|
|
|
|
|