Skip to content

Commit 770029a

Browse files
authored
render on real issue
1 parent 0ade594 commit 770029a

File tree

11 files changed

+132
-49
lines changed

11 files changed

+132
-49
lines changed

.env-template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
REPO_GITHUB_PAT="<github PAT>"
2+
CONFIG_PATH="./testConfig2.json"

TODO.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
2+
- Add support for issues from external repos
3+
- Add the developer stats and badges/achievements
14
- Pass the config JSON file refrence thru the yml file
2-
- issue markers
3-
- Add the PR parsing logic
4-
- Add developer achievements
5+
- Add the PR parsing logic on teh card/issue and render it for the "In review" items
56

6-
- stats on when moved from one column to another ?
7+
- project pulse - graph on how many items fixed on particular day ?
8+
- stats on when moved from one column to another ?

src/interfaces/IProjectData.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export interface IProjectData {
44
inWorkIssues: IWrappedIssue[];
55
doneOrDeployIssues: IWrappedIssue[];
66
allPlannedIssues: IWrappedIssue[];
7-
toSolveIssues: IWrappedIssue[];
7+
issuesToSolve: IWrappedIssue[];
88
// raw:
99
backlogIssues: IWrappedIssue[];
1010
committedIssues: IWrappedIssue[];

src/main.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,7 @@ const updateBoardIssue = async (
5858
return await overwriteBoardIssue(issueContents, config, projectKit);
5959
}
6060

61-
const issue = await projectKit.getBoardIssue(
62-
config.boardIssue,
63-
issueContents,
64-
);
61+
const issue = await projectKit.getBoardIssue(config.boardIssue);
6562

6663
const { body } = issue;
6764
const newBody = body.replace(getRegex(), wrapIssueText(issueContents));

src/octokit/ProjectsOctoKit.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,14 +214,13 @@ export class ProjectsOctoKit extends OctoKitBase {
214214
});
215215
};
216216

217-
public getBoardIssue = async (issueUrl: string, body: string) => {
217+
public getBoardIssue = async (issueUrl: string) => {
218218
const { owner, repo, issueNumber } = parseIssueUrl(issueUrl);
219219

220220
const { status, data } = await this.kit.issues.get({
221221
owner,
222222
repo,
223-
issue_number: issueNumber,
224-
body,
223+
issue_number: issueNumber
225224
});
226225

227226
if (status !== 200) {

src/utils/getProjectData.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export const getProjectData = async (
6565
inWorkIssues,
6666
doneOrDeployIssues,
6767
allPlannedIssues,
68-
toSolveIssues,
68+
issuesToSolve: toSolveIssues,
6969
// plain
7070
backlogIssues,
7171
committedIssues,

src/utils/getProjectStats.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export const getProjectStats = (data: IProjectData, config: IConfig): IProjectSt
6767
inWorkIssues,
6868
doneOrDeployIssues,
6969
allPlannedIssues,
70-
toSolveIssues,
70+
issuesToSolve: toSolveIssues,
7171
// plain
7272
committedIssues,
7373
} = data;

src/views/renderIssue.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ import { IIssueState } from '../interfaces/IIssueState';
22
import { TColumnTypes } from '../interfaces/TColumnTypes';
33
import { TRepoIssue } from '../interfaces/TRepoIssue';
44
import { pluck } from '../utils/pluck';
5+
import { ident } from './ident';
6+
7+
const emojiIcon = (icon: string, title?: string) => {
8+
const iconString = `${icon}${ident(1)}`;
9+
if (!title) {
10+
return iconString;
11+
}
12+
13+
return `<i title="${title}">${iconString}</i>`;
14+
};
515

616
const mapColumnToEmoji = (column: TColumnTypes) => {
717
switch (column) {
@@ -14,19 +24,19 @@ const mapColumnToEmoji = (column: TColumnTypes) => {
1424
}
1525

1626
case TColumnTypes.InReview: {
17-
return '👀 ';
27+
return emojiIcon('👀', column);
1828
}
1929

2030
case TColumnTypes.WaitingToDeploy: {
21-
return '🏗️ ';
31+
return emojiIcon('🏗️', column);
2232
}
2333

2434
case TColumnTypes.Blocked: {
2535
return '';
2636
}
2737

2838
case TColumnTypes.Done: {
29-
return '✅ ';
39+
return emojiIcon('✅', column);
3040
}
3141

3242
default:
@@ -46,7 +56,7 @@ const mapIssueTypeToEmoji = (issue: TRepoIssue) => {
4656
const isBug = labels.map(pluck('name')).map(toLowerCase).includes('bug');
4757

4858
if (isBug) {
49-
return '🐛 ';
59+
return emojiIcon('🐛', 'Bug');
5060
}
5161

5262
return '';

src/views/renderIssuesBlock.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ const renderIssuesSection = (
9999
for (let wrappedIssue of issues) {
100100
const { column, issue } = wrappedIssue;
101101
const item = renderIssue(column, issue, isCheckList);
102-
issueItems.push(`${ident(1)}${item}`);
102+
issueItems.push(`${ident(0)}${item}`);
103103
}
104104

105105
return issueItems.filter(notEmpty).join('\n');
@@ -129,8 +129,9 @@ const renderIssuesList = (
129129
return;
130130
}
131131

132-
const title =
133-
labelName === NONE_LABEL ? undefined : `- **${capitalize(labelName)}**`;
132+
const title = (labelName === NONE_LABEL)
133+
? undefined
134+
: `\n**${capitalize(labelName)}**`;
134135

135136
return renderIssuesSection(issues, projectConfig, title);
136137
});

src/views/renderProjectOverview.ts

Lines changed: 72 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { IConfig } from '../interfaces/IConfig';
22
import { IDeveloperWithIssuesCount } from '../interfaces/IDeveloperWithIssuesCount';
3+
import { IProjectStats } from '../interfaces/IProjectStats';
34
import { IProjectWithData } from '../interfaces/IProjectWithData';
45
import { getProjectStats } from '../utils/getProjectStats';
56
import { ident } from './ident';
@@ -17,60 +18,103 @@ const renderPerLine = (
1718

1819
const left = leftRatio.toFixed(1);
1920
const was = totalRatio.toFixed(1);
20-
return `${ident(identation)}- ${unit}: **${left} left** / **${was} started**`;
21+
return `${ident(identation)}- ${unit}: **${left}** left / **${was}** total`;
2122
};
2223

24+
// const renderDeveloper = (
25+
// developer: IDeveloperWithIssuesCount,
26+
// config: IConfig,
27+
// identation = 0,
28+
// ) => {
29+
// const { login, issuesCount } = developer
30+
31+
// const daysLeft = getWorkDays(config);
32+
// const suffix = (daysLeft)
33+
// ? ` / **${(issuesCount / Math.max(1, daysLeft.businessDaysLeft)).toFixed(1)} per day left**`
34+
// : '';
35+
36+
// return `${ident(identation)}- 🥵 @${login}: **${issuesCount} issues**${suffix}`;
37+
// };
38+
2339
const renderDeveloper = (
24-
developer: IDeveloperWithIssuesCount,
40+
developer: string,
2541
config: IConfig,
2642
identation = 0,
2743
) => {
28-
const { login, issuesCount } = developer
44+
return `${ident(identation)}- @${developer}`;
45+
};
46+
47+
const renderDevelopers = (developers: string[], config: IConfig, identation = 0) => {
48+
const title = `${ident(identation)}- 🧑‍💻 **${developers.length}** developers`;
2949

30-
const daysLeft = getWorkDays(config);
31-
const suffix = (daysLeft)
32-
? ` / **${(issuesCount / Math.max(1, daysLeft.businessDaysLeft)).toFixed(1)} per day left**`
33-
: '';
50+
// const devs = developers
51+
// .sort()
52+
// .map((developer) => {
53+
// return renderDeveloper(developer, config, identation + 1);
54+
// })
55+
// .join('\n');
3456

35-
return `${ident(identation)}- 🥵 @${login}: **${issuesCount} issues**${suffix}`;
57+
return [
58+
title,
59+
// devs,
60+
].join('\n');
3661
};
3762

38-
/**
39-
* Render the `🔭 Overview` section with project stats.
40-
*/
41-
export const renderProjectOverview = (
42-
config: IConfig,
43-
projectWithData: IProjectWithData,
44-
): string => {
45-
const { data } = projectWithData;
63+
const renderIssuesLoad = (stats: IProjectStats, config: IConfig, identation = 0) => {
4664
const {
47-
developers,
4865
issuesDeveloperLeftRatio,
4966
issuesDeveloperRatio,
5067
issuesDayLeftRatio,
5168
issuesDayRatio,
5269
issuesDeveloperDayRatio,
5370
issuesDeveloperDayLeftRatio,
54-
devWithMostAssignedIssues,
55-
} = getProjectStats(data, config);
71+
// devWithMostAssignedIssues,
72+
} = stats;
73+
74+
// Load - 🔥 <b>high</b>
5675

5776
return [
58-
`- 📅 ${renderDaysLeft(config)}`,
59-
`- 🧑‍💻 **${developers.length}** developers`,
60-
renderDeveloper(devWithMostAssignedIssues, config, 1),
61-
`- 🌡️ Issues load per:`,
62-
renderPerLine('day', issuesDayLeftRatio, issuesDayRatio, 1),
77+
'<details>',
78+
'<summary>🌡️ <b>Load</b></summary>',
79+
'',
80+
renderPerLine('issues per day', issuesDayLeftRatio, issuesDayRatio),
6381
renderPerLine(
64-
'developer',
82+
'issues per developer',
6583
issuesDeveloperLeftRatio,
6684
issuesDeveloperRatio,
67-
1,
6885
),
6986
renderPerLine(
70-
'developer/day',
87+
'issues per developer/day',
7188
issuesDeveloperDayLeftRatio,
7289
issuesDeveloperDayRatio,
73-
1,
7490
),
91+
'</details>',
92+
].join('\n');
93+
}
94+
95+
/**
96+
* Render the `🔭 Overview` section with project stats.
97+
*/
98+
export const renderProjectOverview = (
99+
config: IConfig,
100+
projectWithData: IProjectWithData,
101+
): string => {
102+
const { data } = projectWithData;
103+
const {
104+
issuesToSolve,
105+
allPlannedIssues,
106+
} = data;
107+
const stats = getProjectStats(data, config);
108+
109+
const {
110+
developers,
111+
// devWithMostAssignedIssues,
112+
} = stats;
113+
114+
return [
115+
`- 📅 ${renderDaysLeft(config)}`,
116+
`- 🗒️ **${issuesToSolve.length}** issues left / **${allPlannedIssues.length}** total`,
117+
renderDevelopers(developers, config),
118+
renderIssuesLoad(stats, config),
75119
].join('\n');
76120
};

0 commit comments

Comments
 (0)