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

Commit 924b2f1

Browse files
committed
Trigger bot to cleanup columns
1 parent 251e2ba commit 924b2f1

File tree

8 files changed

+133
-222
lines changed

8 files changed

+133
-222
lines changed

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
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

5-
export const getAllOpenPRsAndCardIDsQuery: TypedDocumentNode<GetAllOpenPRsAndCardIDs, GetAllOpenPRsAndCardIDsVariables> = gql`
6-
query GetAllOpenPRsAndCardIDs($after: String) {
5+
export const getAllOpenPRsQuery: TypedDocumentNode<GetAllOpenPRs, GetAllOpenPRsVariables> = gql`
6+
query GetAllOpenPRs($after: String) {
77
repository(owner: "DefinitelyTyped", name: "DefinitelyTyped") {
88
id
99
pullRequests(orderBy: { field: UPDATED_AT, direction: DESC }, states: [OPEN], first: 100, after: $after) {
@@ -12,26 +12,24 @@ query GetAllOpenPRsAndCardIDs($after: String) {
1212
node {
1313
number
1414
updatedAt
15-
projectCards(first: 100) { nodes { id } }
1615
}
1716
}
1817
}
1918
}
2019
}`;
2120

22-
export async function getAllOpenPRsAndCardIDs() {
21+
export async function getAllOpenPRs() {
2322
const prNumbers: number[] = [];
24-
const cardIDs: string[] = [];
2523
let after: string | undefined;
2624
while (true) {
2725
const results = await client.query({
28-
query: getAllOpenPRsAndCardIDsQuery,
26+
query: getAllOpenPRsQuery,
2927
fetchPolicy: "network-only",
3028
variables: { after }
3129
});
3230

3331
if (!results.data.repository?.pullRequests.edges?.length) {
34-
return { prNumbers, cardIDs };
32+
return prNumbers;
3533
}
3634

3735
for (const edge of results.data.repository.pullRequests.edges) {
@@ -41,7 +39,6 @@ export async function getAllOpenPRsAndCardIDs() {
4139
if (!node) continue;
4240

4341
prNumbers.push(node.number);
44-
node.projectCards.nodes?.forEach(n => n && cardIDs.push(n.id));
4542
}
4643
}
4744
}

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_edges_node {
11+
__typename: "PullRequest";
12+
/**
13+
* Identifies the pull request number.
14+
*/
15+
number: number;
16+
/**
17+
* Identifies the date and time when the object was last updated.
18+
*/
19+
updatedAt: any;
20+
}
21+
22+
export interface GetAllOpenPRs_repository_pullRequests_edges {
23+
__typename: "PullRequestEdge";
24+
/**
25+
* A cursor for use in pagination.
26+
*/
27+
cursor: string;
28+
/**
29+
* The item at the end of the edge.
30+
*/
31+
node: GetAllOpenPRs_repository_pullRequests_edges_node | null;
32+
}
33+
34+
export interface GetAllOpenPRs_repository_pullRequests {
35+
__typename: "PullRequestConnection";
36+
/**
37+
* A list of edges.
38+
*/
39+
edges: (GetAllOpenPRs_repository_pullRequests_edges | null)[] | null;
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+
after?: 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)