Skip to content

Commit bf14c29

Browse files
authored
migrate to cards
1 parent 44ec85f commit bf14c29

16 files changed

+329
-213
lines changed

TODO.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,6 @@
3737
🛢️ 🧹 🛀 🧲 🔋 🧭 🔦 ⚙️ ⚡ 🤖 🔧 💳 🔌 🔎 📷 🔬 🕵️ 🔭 👽
3838
🧑‍🚀 🛰️ 📡 🥛 🎂 🧀 🍕 🧰 👷 🚧 🎥 🎬 💩 🎉 📚 ⛄ 🧸 👋 🏆
3939
⚽ 🥅 🤓 🧐 🍭 🍭 🎪 🗡️ 🐉 🧝 🃏 🎲 🧩 🙈 🖊️ 🏛️ 🗝️ 🗺️ 🙉
40-
-->
40+
-->
41+
42+
- Web Experience team ["legomushroom", "plisy", "GideonCheruiyot", "VincentDondain", "wachaudh", "klvnraju"]

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@
3030
"dependencies": {
3131
"@actions/core": "^1.2.6",
3232
"@actions/github": "^4.0.0",
33-
"dotenv": "^8.2.0"
33+
"dotenv": "^8.2.0",
34+
"shortid": "^2.2.16"
3435
},
3536
"devDependencies": {
3637
"@types/jest": "^26.0.10",
3738
"@types/node": "^14.10.0",
39+
"@types/shortid": "^0.0.29",
3840
"@typescript-eslint/parser": "^3.10.1",
3941
"@vercel/ncc": "^0.23.0",
4042
"eslint": "^7.8.1",

schemas/IConfig.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@
9898
"isCheckListItems": {
9999
"description": "If to render issues as check list using the [x] markers.\n\ndefault: false",
100100
"type": "boolean"
101+
},
102+
"developers": {
103+
"description": "Team developers list, if not set, inferred from\nthe assigned GitHub issues.",
104+
"type": "array",
105+
"items": {
106+
"type": "string"
107+
}
101108
}
102109
},
103110
"additionalProperties": false,

src/interfaces/ICardWithIssue.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { TColumnCard } from './TColumnCard';
2+
import { TColumnTypes } from './TColumnTypes';
3+
import { TRepoIssue } from './TRepoIssue';
4+
5+
export interface ICardWithIssue {
6+
column: TColumnTypes;
7+
issue?: TRepoIssue;
8+
card: TColumnCard;
9+
}

src/interfaces/IProject.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,10 @@ export interface IProject {
1818
* default: false
1919
*/
2020
isCheckListItems?: boolean;
21+
22+
/**
23+
* Team developers list, if not set, inferred from
24+
* the assigned GitHub issues.
25+
*/
26+
developers?: string[];
2127
}

src/interfaces/IProjectData.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
import { IWrappedIssue } from './IWrappedIssue';
1+
import { ICardWithIssue } from './ICardWithIssue';
2+
import { IProjectWithConfig } from './IProjectWithConfig';
23

34
export interface IProjectData {
4-
inWorkIssues: IWrappedIssue[];
5-
doneOrDeployIssues: IWrappedIssue[];
6-
allPlannedIssues: IWrappedIssue[];
7-
issuesToSolve: IWrappedIssue[];
5+
project: IProjectWithConfig;
6+
inWorkIssues: ICardWithIssue[];
7+
doneOrDeployIssues: ICardWithIssue[];
8+
allPlannedIssues: ICardWithIssue[];
9+
issuesToSolve: ICardWithIssue[];
810
// raw:
9-
backlogIssues: IWrappedIssue[];
10-
committedIssues: IWrappedIssue[];
11-
progressIssues: IWrappedIssue[];
12-
inReviewIssues: IWrappedIssue[];
13-
blockedIssues: IWrappedIssue[];
14-
waitingToDeployIssues: IWrappedIssue[];
15-
doneIssues: IWrappedIssue[];
11+
backlogIssues: ICardWithIssue[];
12+
committedIssues: ICardWithIssue[];
13+
progressIssues: ICardWithIssue[];
14+
inReviewIssues: ICardWithIssue[];
15+
blockedIssues: ICardWithIssue[];
16+
waitingToDeployIssues: ICardWithIssue[];
17+
doneIssues: ICardWithIssue[];
1618
}
1719

1820

src/interfaces/IProjectStats.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export interface IProjectStats {
1414
issuesDeveloperDayRatio?: number;
1515
issuesDeveloperDayLeftRatio?: number;
1616

17-
devWithMostAssignedIssues: IDeveloperWithIssuesCount;
17+
// devWithMostAssignedIssues: IDeveloperWithIssuesCount;
1818

1919
developers: string[];
2020
}

src/interfaces/IProjectWithConfig.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { TProject } from './TProject';
22
import { TProjectConfig } from './TProjetConfig';
33

4-
54
export interface IProjectWithConfig {
65
project: TProject;
76
projectConfig: TProjectConfig;

src/octokit/ProjectsOctoKit.ts

Lines changed: 21 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { notEmpty } from '../utils/notEmpty';
55

66
import { IRepoSourceConfig } from '../interfaces/IRepoSourceConfig';
77
import { TColumnCard } from '../interfaces/TColumnCard';
8-
// import { TProject } from '../interfaces/TProject';
98
import { TRepoIssue } from '../interfaces/TRepoIssue';
109
import { TColumnTypes } from '../interfaces/TColumnTypes';
1110
import { IWrappedIssue } from '../interfaces/IWrappedIssue';
@@ -15,9 +14,7 @@ import { IParsedIssue } from '../interfaces/IParsedIssue';
1514
import { TProjectColumn } from '../interfaces/TProjectColumn';
1615
import { flattenArray } from '../utils/flatternArray';
1716
import { IParsedRepo } from '../interfaces/IParsedRepo';
18-
// import { IParsedIssue } from '../interfaces/IParsedIssue';
19-
// import { serializeIssuePath } from '../utils/serializeIssuePath';
20-
// import { serializeIssuePath } from '../utils/serializeIssuePath';
17+
import { ICardWithIssue } from '../interfaces/ICardWithIssue';
2118

2219
interface IColumnWithCards {
2320
column: TProjectColumn;
@@ -27,8 +24,6 @@ interface IColumnWithCards {
2724
type TColumnsMap = Record<TColumnTypes, TProjectColumn | undefined>;
2825
type TColumnsWithCardsMap = Record<TColumnTypes, IColumnWithCards | undefined>
2926

30-
type TRepoIssuesMap = Record<string, TRepoIssue[]>
31-
3227
const findColumn = (
3328
columns: TProjectColumn[],
3429
columnName: TColumnTypes,
@@ -40,31 +35,6 @@ const findColumn = (
4035
return result;
4136
};
4237

43-
const wrapIssue = (column: TColumnTypes) => {
44-
return (issue: TRepoIssue) => {
45-
return {
46-
column,
47-
issue,
48-
};
49-
};
50-
};
51-
52-
// const findColumnThrows = (
53-
// projectName: string,
54-
// columns: TProjectColumn[],
55-
// columnName: TColumnTypes,
56-
// ) => {
57-
// const result = findColumn(columns, columnName);
58-
59-
// if (!result) {
60-
// throw new Error(
61-
// `No column "${columnName}" found in project "projectName".`,
62-
// );
63-
// }
64-
65-
// return result;
66-
// };
67-
6838
const getProjectId = (project: IProject | number) => {
6939
return typeof project === 'number' ? project : project.id;
7040
};
@@ -171,7 +141,7 @@ export class ProjectsOctoKit extends OctoKitBase {
171141
column,
172142
cards: await this.getColumnCards(column),
173143
};
174-
});
144+
}).filter(notEmpty);
175145

176146
const columnCardsWithEmpty = await Promise.all(cardPromises);
177147
const columnCards = columnCardsWithEmpty.filter(notEmpty);
@@ -212,6 +182,10 @@ export class ProjectsOctoKit extends OctoKitBase {
212182
return flattenArray(await Promise.all(resultPromises));
213183
};
214184

185+
private isCardIssue = (card: TColumnCard, issue: TRepoIssue): boolean => {
186+
return (card.content_url === issue.url) || (card.note === issue.html_url);
187+
};
188+
215189
private getCardIssueFromNote = (card: TColumnCard): IParsedIssue | null => {
216190
try {
217191
const issue = parseIssueUrl(card.note);
@@ -265,29 +239,31 @@ export class ProjectsOctoKit extends OctoKitBase {
265239
return Object.values(repos);
266240
};
267241

268-
public filterIssuesForColumnCards = async (
242+
public mergeCardsWithIssuesForColumn = (
269243
issues: TRepoIssue[],
270-
columns: TColumnsMap,
244+
columns: TColumnsWithCardsMap,
271245
columnType: TColumnTypes,
272-
): Promise<IWrappedIssue[]> => {
246+
): ICardWithIssue[] => {
273247
// get the column
274248
const column = columns[columnType];
275-
// no column - no issues
249+
// no column - no issue
276250
if (!column) {
277251
return [];
278252
}
279253

280-
const cards = await this.getColumnCards(column);
281-
282-
const cardIssues = issues
283-
.filter((issue) => {
284-
const cardIssue = cards.find((card) => {
285-
return card.content_url === issue.url;
254+
const { cards } = column;
255+
const cardIssues: ICardWithIssue[] = cards
256+
.map((card) => {
257+
const cardIssue = issues.find((issue) => {
258+
return this.isCardIssue(card, issue);
286259
});
287260

288-
return !!cardIssue;
289-
})
290-
.map(wrapIssue(columnType));
261+
return {
262+
card,
263+
issue: cardIssue,
264+
column: columnType,
265+
}
266+
});
291267

292268
return cardIssues;
293269
};

0 commit comments

Comments
 (0)