Skip to content
This repository was archived by the owner on Jul 1, 2024. It is now read-only.

Commit 01b1cc8

Browse files
committed
Trigger bot to cleanup columns
1 parent c91f075 commit 01b1cc8

File tree

8 files changed

+133
-224
lines changed

8 files changed

+133
-224
lines changed

src/queries/all-open-prs-query.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
import { gql, TypedDocumentNode } from "@apollo/client/core";
22
import { client } from "../graphql-client";
3-
import { GetAllOpenPRsAndCardIDs, GetAllOpenPRsAndCardIDsVariables } from "./schema/GetAllOpenPRsAndCardIDs";
3+
import { GetAllOpenPRs, GetAllOpenPRsVariables } from "./schema/GetAllOpenPRs";
44
import { noNullish } from "../util/util";
55

6-
export const getAllOpenPRsAndCardIDsQuery: TypedDocumentNode<GetAllOpenPRsAndCardIDs, GetAllOpenPRsAndCardIDsVariables> = gql`
7-
query GetAllOpenPRsAndCardIDs($endCursor: String) {
6+
export const getAllOpenPRsQuery: TypedDocumentNode<GetAllOpenPRs, GetAllOpenPRsVariables> = gql`
7+
query GetAllOpenPRs($endCursor: String) {
88
repository(owner: "DefinitelyTyped", name: "DefinitelyTyped") {
99
id
1010
pullRequests(states: OPEN, orderBy: { field: UPDATED_AT, direction: DESC }, first: 100, after: $endCursor) {
1111
nodes {
1212
number
13-
projectCards(first: 100) { nodes { id } }
1413
}
1514
pageInfo {
1615
hasNextPage
@@ -20,22 +19,18 @@ query GetAllOpenPRsAndCardIDs($endCursor: String) {
2019
}
2120
}`;
2221

23-
export async function getAllOpenPRsAndCardIDs() {
22+
export async function getAllOpenPRs() {
2423
const prNumbers: number[] = [];
25-
const cardIDs: string[] = [];
2624
let endCursor: string | undefined | null;
2725
while (true) {
2826
const result = await client.query({
29-
query: getAllOpenPRsAndCardIDsQuery,
27+
query: getAllOpenPRsQuery,
3028
fetchPolicy: "no-cache",
3129
variables: { endCursor }
3230
});
3331
prNumbers.push(...noNullish(result.data.repository?.pullRequests.nodes).map(pr => pr.number));
34-
for (const pr of noNullish(result.data.repository?.pullRequests.nodes)) {
35-
cardIDs.push(...noNullish(pr.projectCards.nodes).map(card => card.id));
36-
}
3732
if (!result.data.repository?.pullRequests.pageInfo.hasNextPage) {
38-
return { prNumbers, cardIDs };
33+
return prNumbers;
3934
}
4035
endCursor = result.data.repository.pullRequests.pageInfo.endCursor;
4136
}

src/queries/card-id-to-pr-query.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/queries/projectboard-cards.ts

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { gql, TypedDocumentNode } from "@apollo/client/core";
22
import { client } from "../graphql-client";
33
import { GetProjectBoardCards } from "./schema/GetProjectBoardCards";
4+
import { noNullish } from "../util/util";
45

56
const GetProjectBoardCardsQuery: TypedDocumentNode<GetProjectBoardCards, never> = gql`
67
query GetProjectBoardCards {
@@ -17,6 +18,11 @@ const GetProjectBoardCardsQuery: TypedDocumentNode<GetProjectBoardCards, never>
1718
nodes {
1819
id
1920
updatedAt
21+
content {
22+
... on PullRequest {
23+
number
24+
}
25+
}
2026
}
2127
}
2228
}
@@ -25,16 +31,6 @@ const GetProjectBoardCardsQuery: TypedDocumentNode<GetProjectBoardCards, never>
2531
}
2632
}`;
2733

28-
interface CardInfo {
29-
id: string;
30-
updatedAt: string;
31-
}
32-
interface ColumnInfo {
33-
name: string;
34-
totalCount: number;
35-
cards: CardInfo[];
36-
}
37-
3834
export async function getProjectBoardCards() {
3935
const results = await client.query({
4036
query: GetProjectBoardCardsQuery,
@@ -47,17 +43,13 @@ export async function getProjectBoardCards() {
4743
throw new Error("No project found");
4844
}
4945

50-
const columns: ColumnInfo[] = [];
51-
project.columns.nodes?.forEach(col => {
52-
if (!col) return;
53-
const cards: CardInfo[] = [];
54-
col.cards.nodes?.forEach(card => card && cards.push({ id: card.id, updatedAt: card.updatedAt }));
55-
columns.push({
56-
name: col.name,
57-
totalCount: col.cards.totalCount,
58-
cards
59-
});
60-
});
61-
62-
return columns;
46+
return noNullish(project.columns.nodes).map(column => ({
47+
name: column.name,
48+
totalCount: column.cards.totalCount,
49+
cards: noNullish(column.cards.nodes).map(card => ({
50+
id: card.id,
51+
updatedAt: card.updatedAt,
52+
number: card.content && "number" in card.content ? card.content.number : undefined,
53+
})),
54+
}));
6355
}

src/queries/schema/CardIdToPr.ts

Lines changed: 0 additions & 53 deletions
This file was deleted.

src/queries/schema/GetAllOpenPRs.ts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/* tslint:disable */
2+
/* eslint-disable */
3+
// @generated
4+
// This file was automatically generated and should not be edited.
5+
6+
// ====================================================
7+
// GraphQL query operation: GetAllOpenPRs
8+
// ====================================================
9+
10+
export interface GetAllOpenPRs_repository_pullRequests_nodes {
11+
__typename: "PullRequest";
12+
/**
13+
* Identifies the pull request number.
14+
*/
15+
number: number;
16+
}
17+
18+
export interface GetAllOpenPRs_repository_pullRequests_pageInfo {
19+
__typename: "PageInfo";
20+
/**
21+
* When paginating forwards, are there more items?
22+
*/
23+
hasNextPage: boolean;
24+
/**
25+
* When paginating forwards, the cursor to continue.
26+
*/
27+
endCursor: string | null;
28+
}
29+
30+
export interface GetAllOpenPRs_repository_pullRequests {
31+
__typename: "PullRequestConnection";
32+
/**
33+
* A list of nodes.
34+
*/
35+
nodes: (GetAllOpenPRs_repository_pullRequests_nodes | null)[] | null;
36+
/**
37+
* Information to aid in pagination.
38+
*/
39+
pageInfo: GetAllOpenPRs_repository_pullRequests_pageInfo;
40+
}
41+
42+
export interface GetAllOpenPRs_repository {
43+
__typename: "Repository";
44+
id: string;
45+
/**
46+
* A list of pull requests that have been opened in the repository.
47+
*/
48+
pullRequests: GetAllOpenPRs_repository_pullRequests;
49+
}
50+
51+
export interface GetAllOpenPRs {
52+
/**
53+
* Lookup a given repository by the owner and repository name.
54+
*/
55+
repository: GetAllOpenPRs_repository | null;
56+
}
57+
58+
export interface GetAllOpenPRsVariables {
59+
endCursor?: string | null;
60+
}

src/queries/schema/GetAllOpenPRsAndCardIDs.ts

Lines changed: 0 additions & 77 deletions
This file was deleted.

src/queries/schema/GetProjectBoardCards.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,31 @@
77
// GraphQL query operation: GetProjectBoardCards
88
// ====================================================
99

10+
export interface GetProjectBoardCards_repository_project_columns_nodes_cards_nodes_content_Issue {
11+
__typename: "Issue";
12+
}
13+
14+
export interface GetProjectBoardCards_repository_project_columns_nodes_cards_nodes_content_PullRequest {
15+
__typename: "PullRequest";
16+
/**
17+
* Identifies the pull request number.
18+
*/
19+
number: number;
20+
}
21+
22+
export type GetProjectBoardCards_repository_project_columns_nodes_cards_nodes_content = GetProjectBoardCards_repository_project_columns_nodes_cards_nodes_content_Issue | GetProjectBoardCards_repository_project_columns_nodes_cards_nodes_content_PullRequest;
23+
1024
export interface GetProjectBoardCards_repository_project_columns_nodes_cards_nodes {
1125
__typename: "ProjectCard";
1226
id: string;
1327
/**
1428
* Identifies the date and time when the object was last updated.
1529
*/
1630
updatedAt: any;
31+
/**
32+
* The card content item
33+
*/
34+
content: GetProjectBoardCards_repository_project_columns_nodes_cards_nodes_content | null;
1735
}
1836

1937
export interface GetProjectBoardCards_repository_project_columns_nodes_cards {

0 commit comments

Comments
 (0)