github-issue-tower-defence-management 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +6 -0
- package/.eslintrc.cjs +55 -0
- package/.github/CODEOWNERS +2 -0
- package/.github/workflows/assign-all-cards-to-owner.yml +14 -0
- package/.github/workflows/commit-lint.yml +54 -0
- package/.github/workflows/configs/commitlint.config.js +27 -0
- package/.github/workflows/create-pr.yml +64 -0
- package/.github/workflows/format.yml +25 -0
- package/.github/workflows/publish.yml +47 -0
- package/.github/workflows/test.yml +45 -0
- package/.github/workflows/umino-project.yml +181 -0
- package/.prettierignore +22 -0
- package/.prettierrc +5 -0
- package/CHANGELOG.md +49 -0
- package/CONTRIBUTING.md +107 -0
- package/README.md +108 -0
- package/bin/adapter/entry-points/cli/index.js +26 -0
- package/bin/adapter/entry-points/cli/index.js.map +1 -0
- package/bin/adapter/entry-points/handlers/HandleScheduledEventUseCaseHandler.js +142 -0
- package/bin/adapter/entry-points/handlers/HandleScheduledEventUseCaseHandler.js.map +1 -0
- package/bin/adapter/repositories/AxiosSlackRepository.js +124 -0
- package/bin/adapter/repositories/AxiosSlackRepository.js.map +1 -0
- package/bin/adapter/repositories/BaseGitHubRepository.js +136 -0
- package/bin/adapter/repositories/BaseGitHubRepository.js.map +1 -0
- package/bin/adapter/repositories/GoogleSpreadsheetRepository.js +123 -0
- package/bin/adapter/repositories/GoogleSpreadsheetRepository.js.map +1 -0
- package/bin/adapter/repositories/GraphqlProjectRepository.js +167 -0
- package/bin/adapter/repositories/GraphqlProjectRepository.js.map +1 -0
- package/bin/adapter/repositories/LocalStorageCacheRepository.js +46 -0
- package/bin/adapter/repositories/LocalStorageCacheRepository.js.map +1 -0
- package/bin/adapter/repositories/LocalStorageRepository.js +30 -0
- package/bin/adapter/repositories/LocalStorageRepository.js.map +1 -0
- package/bin/adapter/repositories/SystemDateRepository.js +23 -0
- package/bin/adapter/repositories/SystemDateRepository.js.map +1 -0
- package/bin/adapter/repositories/issue/ApiV3CheerioRestIssueRepository.js +148 -0
- package/bin/adapter/repositories/issue/ApiV3CheerioRestIssueRepository.js.map +1 -0
- package/bin/adapter/repositories/issue/ApiV3IssueRepository.js +48 -0
- package/bin/adapter/repositories/issue/ApiV3IssueRepository.js.map +1 -0
- package/bin/adapter/repositories/issue/CheerioIssueRepository.js +120 -0
- package/bin/adapter/repositories/issue/CheerioIssueRepository.js.map +1 -0
- package/bin/adapter/repositories/issue/GraphqlProjectItemRepository.js +485 -0
- package/bin/adapter/repositories/issue/GraphqlProjectItemRepository.js.map +1 -0
- package/bin/adapter/repositories/issue/InternalGraphqlIssueRepository.js +114 -0
- package/bin/adapter/repositories/issue/InternalGraphqlIssueRepository.js.map +1 -0
- package/bin/adapter/repositories/issue/RestIssueRepository.js +79 -0
- package/bin/adapter/repositories/issue/RestIssueRepository.js.map +1 -0
- package/bin/adapter/repositories/issue/issueTimelineUtils.js +38 -0
- package/bin/adapter/repositories/issue/issueTimelineUtils.js.map +1 -0
- package/bin/adapter/repositories/utils.js +45 -0
- package/bin/adapter/repositories/utils.js.map +1 -0
- package/bin/domain/entities/Issue.js +3 -0
- package/bin/domain/entities/Issue.js.map +1 -0
- package/bin/domain/entities/Member.js +3 -0
- package/bin/domain/entities/Member.js.map +1 -0
- package/bin/domain/entities/Project.js +3 -0
- package/bin/domain/entities/Project.js.map +1 -0
- package/bin/domain/entities/ProjectField.js +3 -0
- package/bin/domain/entities/ProjectField.js.map +1 -0
- package/bin/domain/entities/ProjectFieldSingleSelect.js +3 -0
- package/bin/domain/entities/ProjectFieldSingleSelect.js.map +1 -0
- package/bin/domain/entities/ProjectFieldSingleSelectOption.js +3 -0
- package/bin/domain/entities/ProjectFieldSingleSelectOption.js.map +1 -0
- package/bin/domain/entities/WorkingTime.js +3 -0
- package/bin/domain/entities/WorkingTime.js.map +1 -0
- package/bin/domain/usecases/ActionAnnouncementUseCase.js +46 -0
- package/bin/domain/usecases/ActionAnnouncementUseCase.js.map +1 -0
- package/bin/domain/usecases/AnalyzeProblemByIssueUseCase.js +116 -0
- package/bin/domain/usecases/AnalyzeProblemByIssueUseCase.js.map +1 -0
- package/bin/domain/usecases/ClearNextActionHourUseCase.js +38 -0
- package/bin/domain/usecases/ClearNextActionHourUseCase.js.map +1 -0
- package/bin/domain/usecases/GenerateWorkingTimeReportUseCase.js +180 -0
- package/bin/domain/usecases/GenerateWorkingTimeReportUseCase.js.map +1 -0
- package/bin/domain/usecases/HandleScheduledEventUseCase.js +122 -0
- package/bin/domain/usecases/HandleScheduledEventUseCase.js.map +1 -0
- package/bin/domain/usecases/SetWorkflowManagementIssueToStoryUseCase.js +35 -0
- package/bin/domain/usecases/SetWorkflowManagementIssueToStoryUseCase.js.map +1 -0
- package/bin/domain/usecases/adapter-interfaces/DateRepository.js +3 -0
- package/bin/domain/usecases/adapter-interfaces/DateRepository.js.map +1 -0
- package/bin/domain/usecases/adapter-interfaces/IssueRepository.js +3 -0
- package/bin/domain/usecases/adapter-interfaces/IssueRepository.js.map +1 -0
- package/bin/domain/usecases/adapter-interfaces/ProjectRepository.js +3 -0
- package/bin/domain/usecases/adapter-interfaces/ProjectRepository.js.map +1 -0
- package/bin/domain/usecases/adapter-interfaces/SlackRepository.js +3 -0
- package/bin/domain/usecases/adapter-interfaces/SlackRepository.js.map +1 -0
- package/bin/domain/usecases/adapter-interfaces/SpreadsheetRepository.js +3 -0
- package/bin/domain/usecases/adapter-interfaces/SpreadsheetRepository.js.map +1 -0
- package/bin/index.js +13 -0
- package/bin/index.js.map +1 -0
- package/commitlint.config.js +6 -0
- package/jest.config.js +19 -0
- package/package.json +80 -0
- package/renovate.json +37 -0
- package/src/adapter/entry-points/cli/index.test.ts +20 -0
- package/src/adapter/entry-points/cli/index.ts +36 -0
- package/src/adapter/entry-points/handlers/HandleScheduledEventUseCaseHandler.ts +95 -0
- package/src/adapter/repositories/AxiosSlackRepository.test.ts +119 -0
- package/src/adapter/repositories/AxiosSlackRepository.ts +184 -0
- package/src/adapter/repositories/BaseGitHubRepository.test.ts +95 -0
- package/src/adapter/repositories/BaseGitHubRepository.ts +172 -0
- package/src/adapter/repositories/GoogleSpreadsheetRepository.test.ts +124 -0
- package/src/adapter/repositories/GoogleSpreadsheetRepository.ts +151 -0
- package/src/adapter/repositories/GraphqlProjectRepository.test.ts +46 -0
- package/src/adapter/repositories/GraphqlProjectRepository.ts +236 -0
- package/src/adapter/repositories/LocalStorageCacheRepository.test.ts +146 -0
- package/src/adapter/repositories/LocalStorageCacheRepository.ts +53 -0
- package/src/adapter/repositories/LocalStorageRepository.integration.test.ts +142 -0
- package/src/adapter/repositories/LocalStorageRepository.test.ts +161 -0
- package/src/adapter/repositories/LocalStorageRepository.ts +21 -0
- package/src/adapter/repositories/SystemDateRepository.ts +20 -0
- package/src/adapter/repositories/issue/ApiV3CheerioRestIssueRepository.test.ts +158 -0
- package/src/adapter/repositories/issue/ApiV3CheerioRestIssueRepository.ts +274 -0
- package/src/adapter/repositories/issue/ApiV3IssueRepository.test.ts +26 -0
- package/src/adapter/repositories/issue/ApiV3IssueRepository.ts +59 -0
- package/src/adapter/repositories/issue/CheerioIssueRepository.test.ts +6610 -0
- package/src/adapter/repositories/issue/CheerioIssueRepository.ts +127 -0
- package/src/adapter/repositories/issue/GraphqlProjectItemRepository.test.ts +49 -0
- package/src/adapter/repositories/issue/GraphqlProjectItemRepository.ts +745 -0
- package/src/adapter/repositories/issue/InternalGraphqlIssueRepository.test.ts +71 -0
- package/src/adapter/repositories/issue/InternalGraphqlIssueRepository.ts +263 -0
- package/src/adapter/repositories/issue/RestIssueRepository.test.ts +29 -0
- package/src/adapter/repositories/issue/RestIssueRepository.ts +105 -0
- package/src/adapter/repositories/issue/issueTimelineUtils.test.ts +79 -0
- package/src/adapter/repositories/issue/issueTimelineUtils.ts +52 -0
- package/src/adapter/repositories/utils.test.ts +40 -0
- package/src/adapter/repositories/utils.ts +50 -0
- package/src/domain/entities/Issue.ts +23 -0
- package/src/domain/entities/Member.ts +3 -0
- package/src/domain/entities/Project.ts +29 -0
- package/src/domain/entities/ProjectField.ts +3 -0
- package/src/domain/entities/ProjectFieldSingleSelect.ts +8 -0
- package/src/domain/entities/ProjectFieldSingleSelectOption.ts +8 -0
- package/src/domain/entities/WorkingTime.ts +8 -0
- package/src/domain/usecases/ActionAnnouncementUseCase.ts +76 -0
- package/src/domain/usecases/AnalyzeProblemByIssueUseCase.ts +209 -0
- package/src/domain/usecases/ClearNextActionHourUseCase.ts +51 -0
- package/src/domain/usecases/GenerateWorkingTimeReportUseCase.test.ts +382 -0
- package/src/domain/usecases/GenerateWorkingTimeReportUseCase.ts +284 -0
- package/src/domain/usecases/HandleScheduledEventUseCase.test.ts +58 -0
- package/src/domain/usecases/HandleScheduledEventUseCase.ts +209 -0
- package/src/domain/usecases/SetWorkflowManagementIssueToStoryUseCase.ts +46 -0
- package/src/domain/usecases/adapter-interfaces/DateRepository.ts +5 -0
- package/src/domain/usecases/adapter-interfaces/IssueRepository.ts +44 -0
- package/src/domain/usecases/adapter-interfaces/ProjectRepository.ts +6 -0
- package/src/domain/usecases/adapter-interfaces/SlackRepository.ts +20 -0
- package/src/domain/usecases/adapter-interfaces/SpreadsheetRepository.ts +18 -0
- package/src/index.test.ts +8 -0
- package/src/index.ts +7 -0
- package/tsconfig.build.json +11 -0
- package/tsconfig.json +22 -0
- package/types/adapter/entry-points/cli/index.d.ts +3 -0
- package/types/adapter/entry-points/cli/index.d.ts.map +1 -0
- package/types/adapter/entry-points/handlers/HandleScheduledEventUseCaseHandler.d.ts +11 -0
- package/types/adapter/entry-points/handlers/HandleScheduledEventUseCaseHandler.d.ts.map +1 -0
- package/types/adapter/repositories/AxiosSlackRepository.d.ts +13 -0
- package/types/adapter/repositories/AxiosSlackRepository.d.ts.map +1 -0
- package/types/adapter/repositories/BaseGitHubRepository.d.ts +32 -0
- package/types/adapter/repositories/BaseGitHubRepository.d.ts.map +1 -0
- package/types/adapter/repositories/GoogleSpreadsheetRepository.d.ts +13 -0
- package/types/adapter/repositories/GoogleSpreadsheetRepository.d.ts.map +1 -0
- package/types/adapter/repositories/GraphqlProjectRepository.d.ts +13 -0
- package/types/adapter/repositories/GraphqlProjectRepository.d.ts.map +1 -0
- package/types/adapter/repositories/LocalStorageCacheRepository.d.ts +12 -0
- package/types/adapter/repositories/LocalStorageCacheRepository.d.ts.map +1 -0
- package/types/adapter/repositories/LocalStorageRepository.d.ts +7 -0
- package/types/adapter/repositories/LocalStorageRepository.d.ts.map +1 -0
- package/types/adapter/repositories/SystemDateRepository.d.ts +7 -0
- package/types/adapter/repositories/SystemDateRepository.d.ts.map +1 -0
- package/types/adapter/repositories/issue/ApiV3CheerioRestIssueRepository.d.ts +38 -0
- package/types/adapter/repositories/issue/ApiV3CheerioRestIssueRepository.d.ts.map +1 -0
- package/types/adapter/repositories/issue/ApiV3IssueRepository.d.ts +17 -0
- package/types/adapter/repositories/issue/ApiV3IssueRepository.d.ts.map +1 -0
- package/types/adapter/repositories/issue/CheerioIssueRepository.d.ts +31 -0
- package/types/adapter/repositories/issue/CheerioIssueRepository.d.ts.map +1 -0
- package/types/adapter/repositories/issue/GraphqlProjectItemRepository.d.ts +39 -0
- package/types/adapter/repositories/issue/GraphqlProjectItemRepository.d.ts.map +1 -0
- package/types/adapter/repositories/issue/InternalGraphqlIssueRepository.d.ts +83 -0
- package/types/adapter/repositories/issue/InternalGraphqlIssueRepository.d.ts.map +1 -0
- package/types/adapter/repositories/issue/RestIssueRepository.d.ts +16 -0
- package/types/adapter/repositories/issue/RestIssueRepository.d.ts.map +1 -0
- package/types/adapter/repositories/issue/issueTimelineUtils.d.ts +12 -0
- package/types/adapter/repositories/issue/issueTimelineUtils.d.ts.map +1 -0
- package/types/adapter/repositories/utils.d.ts +4 -0
- package/types/adapter/repositories/utils.d.ts.map +1 -0
- package/types/domain/entities/Issue.d.ts +24 -0
- package/types/domain/entities/Issue.d.ts.map +1 -0
- package/types/domain/entities/Member.d.ts +4 -0
- package/types/domain/entities/Member.d.ts.map +1 -0
- package/types/domain/entities/Project.d.ts +29 -0
- package/types/domain/entities/Project.d.ts.map +1 -0
- package/types/domain/entities/ProjectField.d.ts +3 -0
- package/types/domain/entities/ProjectField.d.ts.map +1 -0
- package/types/domain/entities/ProjectFieldSingleSelect.d.ts +8 -0
- package/types/domain/entities/ProjectFieldSingleSelect.d.ts.map +1 -0
- package/types/domain/entities/ProjectFieldSingleSelectOption.d.ts +8 -0
- package/types/domain/entities/ProjectFieldSingleSelectOption.d.ts.map +1 -0
- package/types/domain/entities/WorkingTime.d.ts +8 -0
- package/types/domain/entities/WorkingTime.d.ts.map +1 -0
- package/types/domain/usecases/ActionAnnouncementUseCase.d.ts +17 -0
- package/types/domain/usecases/ActionAnnouncementUseCase.d.ts.map +1 -0
- package/types/domain/usecases/AnalyzeProblemByIssueUseCase.d.ts +26 -0
- package/types/domain/usecases/AnalyzeProblemByIssueUseCase.d.ts.map +1 -0
- package/types/domain/usecases/ClearNextActionHourUseCase.d.ts +14 -0
- package/types/domain/usecases/ClearNextActionHourUseCase.d.ts.map +1 -0
- package/types/domain/usecases/GenerateWorkingTimeReportUseCase.d.ts +50 -0
- package/types/domain/usecases/GenerateWorkingTimeReportUseCase.d.ts.map +1 -0
- package/types/domain/usecases/HandleScheduledEventUseCase.d.ts +63 -0
- package/types/domain/usecases/HandleScheduledEventUseCase.d.ts.map +1 -0
- package/types/domain/usecases/SetWorkflowManagementIssueToStoryUseCase.d.ts +14 -0
- package/types/domain/usecases/SetWorkflowManagementIssueToStoryUseCase.d.ts.map +1 -0
- package/types/domain/usecases/adapter-interfaces/DateRepository.d.ts +6 -0
- package/types/domain/usecases/adapter-interfaces/DateRepository.d.ts.map +1 -0
- package/types/domain/usecases/adapter-interfaces/IssueRepository.d.ts +23 -0
- package/types/domain/usecases/adapter-interfaces/IssueRepository.d.ts.map +1 -0
- package/types/domain/usecases/adapter-interfaces/ProjectRepository.d.ts +6 -0
- package/types/domain/usecases/adapter-interfaces/ProjectRepository.d.ts.map +1 -0
- package/types/domain/usecases/adapter-interfaces/SlackRepository.d.ts +9 -0
- package/types/domain/usecases/adapter-interfaces/SlackRepository.d.ts.map +1 -0
- package/types/domain/usecases/adapter-interfaces/SpreadsheetRepository.d.ts +6 -0
- package/types/domain/usecases/adapter-interfaces/SpreadsheetRepository.d.ts.map +1 -0
- package/types/index.d.ts +10 -0
- package/types/index.d.ts.map +1 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { calcrateDuration, totalDuration } from './utils';
|
|
2
|
+
|
|
3
|
+
describe('utils', () => {
|
|
4
|
+
describe('calculateDuration', () => {
|
|
5
|
+
test.each`
|
|
6
|
+
start | end | expected
|
|
7
|
+
${'0:50'} | ${'1:30'} | ${'00:40'}
|
|
8
|
+
${'23:50'} | ${'0:00'} | ${'00:10'}
|
|
9
|
+
${'0:20'} | ${'0:10'} | ${'23:50'}
|
|
10
|
+
`(
|
|
11
|
+
'should return $expected',
|
|
12
|
+
({
|
|
13
|
+
start,
|
|
14
|
+
end,
|
|
15
|
+
expected,
|
|
16
|
+
}: {
|
|
17
|
+
start: string;
|
|
18
|
+
end: string;
|
|
19
|
+
expected: string;
|
|
20
|
+
}) => {
|
|
21
|
+
const result = calcrateDuration(start, end);
|
|
22
|
+
expect(result).toEqual(expected);
|
|
23
|
+
},
|
|
24
|
+
);
|
|
25
|
+
});
|
|
26
|
+
describe('totalDuration', () => {
|
|
27
|
+
test.each`
|
|
28
|
+
durations | expected
|
|
29
|
+
${['0:50', '1:30']} | ${'02:20'}
|
|
30
|
+
${['23:50', '0:00']} | ${'23:50'}
|
|
31
|
+
${['0:20', '0:10']} | ${'00:30'}
|
|
32
|
+
`(
|
|
33
|
+
'should return $expected',
|
|
34
|
+
({ durations, expected }: { durations: string[]; expected: string }) => {
|
|
35
|
+
const result = totalDuration(durations);
|
|
36
|
+
expect(result).toEqual(expected);
|
|
37
|
+
},
|
|
38
|
+
);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// 0:50 , 1:10 = 0:20
|
|
2
|
+
// 23:50 , 0:00 = 0:10
|
|
3
|
+
// 0:20, 0:10 = 23:50
|
|
4
|
+
export const calcrateDuration = (
|
|
5
|
+
start: string, // HH:mm
|
|
6
|
+
end: string, // HH:mm
|
|
7
|
+
): string => {
|
|
8
|
+
const [startHour, startMinute] = start.split(':').map((s) => parseInt(s, 10));
|
|
9
|
+
const [endHour, endMinute] = end.split(':').map((s) => parseInt(s, 10));
|
|
10
|
+
|
|
11
|
+
let durationHour = endHour - startHour;
|
|
12
|
+
let durationMinute = endMinute - startMinute;
|
|
13
|
+
|
|
14
|
+
if (durationMinute < 0) {
|
|
15
|
+
durationHour -= 1;
|
|
16
|
+
durationMinute += 60;
|
|
17
|
+
}
|
|
18
|
+
if (durationHour < 0) {
|
|
19
|
+
durationHour += 24;
|
|
20
|
+
}
|
|
21
|
+
return `${String(durationHour).padStart(2, '0')}:${String(durationMinute).padStart(2, '0')}`;
|
|
22
|
+
};
|
|
23
|
+
export const totalDuration = (
|
|
24
|
+
durations: string[], // HH:mm
|
|
25
|
+
): string => {
|
|
26
|
+
const total = durations.reduce(
|
|
27
|
+
(acc, cur) => {
|
|
28
|
+
const [hour, minute] = cur.split(':').map((s) => parseInt(s, 10));
|
|
29
|
+
return {
|
|
30
|
+
hour: acc.hour + hour,
|
|
31
|
+
minute: acc.minute + minute,
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
{ hour: 0, minute: 0 },
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
const totalHour = total.hour + Math.floor(total.minute / 60);
|
|
38
|
+
const totalMinute = total.minute % 60;
|
|
39
|
+
|
|
40
|
+
return `${String(totalHour).padStart(2, '0')}:${String(totalMinute).padStart(2, '0')}`;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const normalizeFieldName = (fieldName: string) => {
|
|
44
|
+
return fieldName
|
|
45
|
+
.toLowerCase()
|
|
46
|
+
.replace(' ', '')
|
|
47
|
+
.replace('-', '')
|
|
48
|
+
.replace(' ', '')
|
|
49
|
+
.replace(' ', '');
|
|
50
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { WorkingTime } from './WorkingTime';
|
|
2
|
+
import { Member } from './Member';
|
|
3
|
+
export type Label = string;
|
|
4
|
+
export type Issue = {
|
|
5
|
+
nameWithOwner: string;
|
|
6
|
+
number: number;
|
|
7
|
+
title: string;
|
|
8
|
+
state: 'OPEN' | 'CLOSED' | 'MERGED';
|
|
9
|
+
status: string | null;
|
|
10
|
+
story: string | null;
|
|
11
|
+
nextActionDate: Date | null;
|
|
12
|
+
nextActionHour: number | null;
|
|
13
|
+
estimationMinutes: number | null;
|
|
14
|
+
url: string;
|
|
15
|
+
assignees: Member['name'][];
|
|
16
|
+
workingTimeline: WorkingTime[];
|
|
17
|
+
labels: Label[];
|
|
18
|
+
org: string;
|
|
19
|
+
repo: string;
|
|
20
|
+
body: string;
|
|
21
|
+
itemId: string;
|
|
22
|
+
isPr: boolean;
|
|
23
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type Project = {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
// fields: ProjectField[];
|
|
5
|
+
nextActionDate: {
|
|
6
|
+
name: string;
|
|
7
|
+
fieldId: string;
|
|
8
|
+
} | null;
|
|
9
|
+
nextActionHour: {
|
|
10
|
+
name: string;
|
|
11
|
+
fieldId: string;
|
|
12
|
+
} | null;
|
|
13
|
+
story: {
|
|
14
|
+
name: string;
|
|
15
|
+
fieldId: string;
|
|
16
|
+
stories: {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
}[];
|
|
20
|
+
workflowManagementStory: {
|
|
21
|
+
id: string;
|
|
22
|
+
name: string;
|
|
23
|
+
};
|
|
24
|
+
} | null;
|
|
25
|
+
remainingEstimationMinutes: {
|
|
26
|
+
name: string;
|
|
27
|
+
fieldId: string;
|
|
28
|
+
} | null;
|
|
29
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Issue } from '../entities/Issue';
|
|
2
|
+
import { Member } from '../entities/Member';
|
|
3
|
+
import { IssueRepository } from './adapter-interfaces/IssueRepository';
|
|
4
|
+
import { Project } from '../entities/Project';
|
|
5
|
+
|
|
6
|
+
export class ActionAnnouncementUseCase {
|
|
7
|
+
constructor(
|
|
8
|
+
readonly issueRepository: Pick<
|
|
9
|
+
IssueRepository,
|
|
10
|
+
'createNewIssue' | 'updateIssue'
|
|
11
|
+
>,
|
|
12
|
+
) {}
|
|
13
|
+
|
|
14
|
+
run = async (input: {
|
|
15
|
+
targetDates: Date[];
|
|
16
|
+
project: Project;
|
|
17
|
+
issues: Issue[];
|
|
18
|
+
cacheUsed: boolean;
|
|
19
|
+
members: Member['name'][];
|
|
20
|
+
manager: Member['name'];
|
|
21
|
+
}): Promise<void> => {
|
|
22
|
+
if (input.cacheUsed || input.targetDates.length === 0) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const now = input.targetDates[input.targetDates.length - 1];
|
|
26
|
+
const isTargetIssue = (issue: Issue): boolean => {
|
|
27
|
+
return (
|
|
28
|
+
issue.labels.includes('action:announcement') &&
|
|
29
|
+
(issue.nextActionDate === null ||
|
|
30
|
+
issue.nextActionDate.getTime() <= now.getTime()) &&
|
|
31
|
+
issue.state === 'OPEN'
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
const actionAnnouncementIssues = input.issues.filter((issue) =>
|
|
35
|
+
isTargetIssue(issue),
|
|
36
|
+
);
|
|
37
|
+
for (const issue of actionAnnouncementIssues) {
|
|
38
|
+
for (const member of input.members) {
|
|
39
|
+
try {
|
|
40
|
+
await this.issueRepository.createNewIssue(
|
|
41
|
+
issue.org,
|
|
42
|
+
issue.repo,
|
|
43
|
+
`Announcement #${issue.number}: ${issue.title} / ${member}`,
|
|
44
|
+
`Hi @${member},
|
|
45
|
+
|
|
46
|
+
Please take a look at the announcement in the issue ${issue.url} and take necessary actions :pray:
|
|
47
|
+
`,
|
|
48
|
+
[member],
|
|
49
|
+
[
|
|
50
|
+
...issue.labels.filter(
|
|
51
|
+
(label) => label !== 'action:announcement',
|
|
52
|
+
),
|
|
53
|
+
'story:workflow-management',
|
|
54
|
+
],
|
|
55
|
+
);
|
|
56
|
+
} catch (e) {
|
|
57
|
+
await this.issueRepository.createNewIssue(
|
|
58
|
+
issue.org,
|
|
59
|
+
issue.repo,
|
|
60
|
+
`Error occured while creating working report for ${member}`,
|
|
61
|
+
`${JSON.stringify(e)}`,
|
|
62
|
+
[input.manager],
|
|
63
|
+
['bug'],
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
await new Promise((resolve) => setTimeout(resolve, 5000));
|
|
67
|
+
}
|
|
68
|
+
await this.issueRepository.updateIssue({
|
|
69
|
+
...issue,
|
|
70
|
+
labels: issue.labels
|
|
71
|
+
.filter((label) => label !== 'action:announcement')
|
|
72
|
+
.concat('announcement'),
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { Issue } from '../entities/Issue';
|
|
2
|
+
import { IssueRepository } from './adapter-interfaces/IssueRepository';
|
|
3
|
+
import { Project } from '../entities/Project';
|
|
4
|
+
import { Member } from '../entities/Member';
|
|
5
|
+
import { DateRepository } from './adapter-interfaces/DateRepository';
|
|
6
|
+
|
|
7
|
+
export class AnalyzeProblemByIssueUseCase {
|
|
8
|
+
constructor(
|
|
9
|
+
readonly issueRepository: Pick<IssueRepository, 'createNewIssue'>,
|
|
10
|
+
readonly dateRepository: Pick<DateRepository, 'formatDurationToHHMM'>,
|
|
11
|
+
) {}
|
|
12
|
+
|
|
13
|
+
run = async (input: {
|
|
14
|
+
targetDates: Date[];
|
|
15
|
+
project: Project;
|
|
16
|
+
issues: Issue[];
|
|
17
|
+
cacheUsed: boolean;
|
|
18
|
+
manager: Member['name'];
|
|
19
|
+
org: string;
|
|
20
|
+
repo: string;
|
|
21
|
+
}): Promise<void> => {
|
|
22
|
+
const story = input.project.story;
|
|
23
|
+
if (
|
|
24
|
+
!story ||
|
|
25
|
+
!input.targetDates.find(
|
|
26
|
+
(targetDate) =>
|
|
27
|
+
targetDate.getHours() === 7 && targetDate.getMinutes() === 0,
|
|
28
|
+
)
|
|
29
|
+
) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const isTargetIssue = (issue: Issue): boolean => {
|
|
33
|
+
return (
|
|
34
|
+
!issue.isPr &&
|
|
35
|
+
(issue.nextActionDate === null ||
|
|
36
|
+
issue.nextActionDate.getTime() <= input.targetDates[0].getTime()) &&
|
|
37
|
+
issue.nextActionHour === null
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
const summaryStoryIssue = new Map<
|
|
41
|
+
string,
|
|
42
|
+
Map<
|
|
43
|
+
Issue,
|
|
44
|
+
{
|
|
45
|
+
totalWorkingTime: number;
|
|
46
|
+
totalWorkingTimeByAssignee: Map<string, number>;
|
|
47
|
+
}
|
|
48
|
+
>
|
|
49
|
+
>();
|
|
50
|
+
const targetStory = input.project.story?.stories.slice(0, 12) || [];
|
|
51
|
+
for (const story of targetStory) {
|
|
52
|
+
summaryStoryIssue.set(story.name, new Map());
|
|
53
|
+
for (const issue of input.issues) {
|
|
54
|
+
if (issue.story !== story.name || !isTargetIssue(issue)) {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
const totalWorkingTimeByAssignee =
|
|
58
|
+
this.calculateTotalWorkingMinutesByAssignee(issue);
|
|
59
|
+
const totalWorkingTime = Math.round(
|
|
60
|
+
Array.from(totalWorkingTimeByAssignee.values()).reduce(
|
|
61
|
+
(a, b) => a + b,
|
|
62
|
+
0,
|
|
63
|
+
),
|
|
64
|
+
);
|
|
65
|
+
const issueSummary: {
|
|
66
|
+
totalWorkingTime: number;
|
|
67
|
+
totalWorkingTimeByAssignee: Map<string, number>;
|
|
68
|
+
} = {
|
|
69
|
+
totalWorkingTime,
|
|
70
|
+
totalWorkingTimeByAssignee,
|
|
71
|
+
};
|
|
72
|
+
summaryStoryIssue.get(story.name)?.set(issue, issueSummary);
|
|
73
|
+
// if (totalWorkingTime < 240 || totalWorkingTime > 1440) {
|
|
74
|
+
// continue;
|
|
75
|
+
// }
|
|
76
|
+
// await this.issueRepository.createNewIssue(
|
|
77
|
+
// issue.org,
|
|
78
|
+
// issue.repo,
|
|
79
|
+
// `Please share the situation about #${issue.number} (${issue.title}) / total working time: ${totalWorkingTime} minutes`,
|
|
80
|
+
// this.createQuestionIssueBody(
|
|
81
|
+
// issue,
|
|
82
|
+
// totalWorkingTime,
|
|
83
|
+
// totalWorkingTimeByAssignee,
|
|
84
|
+
// ),
|
|
85
|
+
//
|
|
86
|
+
// [input.manager],
|
|
87
|
+
// ['story:workflow-management'],
|
|
88
|
+
// );
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
await this.issueRepository.createNewIssue(
|
|
92
|
+
input.org,
|
|
93
|
+
input.repo,
|
|
94
|
+
`Summary of story issues`,
|
|
95
|
+
this.createSummaryIssueBody(summaryStoryIssue),
|
|
96
|
+
|
|
97
|
+
[input.manager],
|
|
98
|
+
['story:workflow-management'],
|
|
99
|
+
);
|
|
100
|
+
};
|
|
101
|
+
createSummaryIssueBody = (
|
|
102
|
+
summaryStoryIssue: Map<
|
|
103
|
+
string,
|
|
104
|
+
Map<
|
|
105
|
+
Issue,
|
|
106
|
+
{
|
|
107
|
+
totalWorkingTime: number;
|
|
108
|
+
totalWorkingTimeByAssignee: Map<string, number>;
|
|
109
|
+
}
|
|
110
|
+
>
|
|
111
|
+
>,
|
|
112
|
+
): string => {
|
|
113
|
+
let noMultipleNewLineBody = `${Array.from(summaryStoryIssue)
|
|
114
|
+
.map(
|
|
115
|
+
([story, issues]) =>
|
|
116
|
+
`## ${this.dateRepository.formatDurationToHHMM(Array.from(issues.values()).reduce((a, b) => a + b.totalWorkingTime, 0))} ${story}
|
|
117
|
+
${Array.from(issues)
|
|
118
|
+
.map(
|
|
119
|
+
([issue, { totalWorkingTime, totalWorkingTimeByAssignee }]) =>
|
|
120
|
+
`- ${this.dateRepository.formatDurationToHHMM(totalWorkingTime)} ${totalWorkingTime > 300 ? ':warning: over 300min' : ''} ${issue.url} ${issue.assignees.map((a) => `@${a}`).join(' ')} ${issue.labels
|
|
121
|
+
.map(
|
|
122
|
+
(label) =>
|
|
123
|
+
`https://github.com/${issue.nameWithOwner}/labels/${encodeURI(label).replace(/:/g, '%3A')}`,
|
|
124
|
+
)
|
|
125
|
+
.join(' ')}
|
|
126
|
+
${issue.workingTimeline.length > 0 ? ` - Total` : ''}
|
|
127
|
+
${Array.from(totalWorkingTimeByAssignee)
|
|
128
|
+
.map(
|
|
129
|
+
([author, workingMinutes]) =>
|
|
130
|
+
` - ${this.dateRepository.formatDurationToHHMM(workingMinutes)}, @${author}`,
|
|
131
|
+
)
|
|
132
|
+
.join('\n')}
|
|
133
|
+
${issue.workingTimeline.length > 0 ? ` - Timeline` : ''}
|
|
134
|
+
${issue.workingTimeline
|
|
135
|
+
.map(
|
|
136
|
+
({ startedAt, endedAt, durationMinutes, author }) =>
|
|
137
|
+
` - ${this.dateRepository.formatDurationToHHMM(
|
|
138
|
+
startedAt.getMinutes(),
|
|
139
|
+
)}, ${this.dateRepository.formatDurationToHHMM(
|
|
140
|
+
endedAt.getMinutes(),
|
|
141
|
+
)}, ${this.dateRepository.formatDurationToHHMM(durationMinutes)}, @${author}`,
|
|
142
|
+
)
|
|
143
|
+
.join('\n')}`,
|
|
144
|
+
)
|
|
145
|
+
.join('\n')}`,
|
|
146
|
+
)
|
|
147
|
+
.join('\n')}`;
|
|
148
|
+
while (noMultipleNewLineBody.includes('\n\n')) {
|
|
149
|
+
noMultipleNewLineBody = noMultipleNewLineBody.replace('\n\n', '\n');
|
|
150
|
+
}
|
|
151
|
+
return noMultipleNewLineBody;
|
|
152
|
+
};
|
|
153
|
+
createQuestionIssueBody = (
|
|
154
|
+
issue: Issue,
|
|
155
|
+
totalWorkingTime: number,
|
|
156
|
+
totalWorkingTimeByAssignee: Map<string, number>,
|
|
157
|
+
): string => {
|
|
158
|
+
return `Hi,
|
|
159
|
+
I worry about the situation of #${issue.number} (${issue.title}) because the total working time is over 120 minutes.
|
|
160
|
+
Could you please share the situation? :pray:
|
|
161
|
+
|
|
162
|
+
## Total
|
|
163
|
+
${this.dateRepository.formatDurationToHHMM(totalWorkingTime)}
|
|
164
|
+
|
|
165
|
+
## From the record
|
|
166
|
+
Working Minutes, Author,
|
|
167
|
+
${Array.from(totalWorkingTimeByAssignee)
|
|
168
|
+
.map(
|
|
169
|
+
([author, workingMinutes]) =>
|
|
170
|
+
`${this.dateRepository.formatDurationToHHMM(workingMinutes)}, ${author}`,
|
|
171
|
+
)
|
|
172
|
+
.join('\n')}
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
## Timeline
|
|
176
|
+
Start, End, Duration, Author
|
|
177
|
+
${issue.workingTimeline
|
|
178
|
+
.map(
|
|
179
|
+
({ startedAt, endedAt, durationMinutes, author }) =>
|
|
180
|
+
`${this.dateRepository.formatDurationToHHMM(
|
|
181
|
+
startedAt.getMinutes(),
|
|
182
|
+
)}, ${this.dateRepository.formatDurationToHHMM(
|
|
183
|
+
endedAt.getMinutes(),
|
|
184
|
+
)}, ${this.dateRepository.formatDurationToHHMM(durationMinutes)}, ${author}`,
|
|
185
|
+
)
|
|
186
|
+
.join('\n')}
|
|
187
|
+
`;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
calculateTotalWorkingMinutesByAssignee = (
|
|
191
|
+
issue: Issue,
|
|
192
|
+
): Map<string, number> => {
|
|
193
|
+
const workingTimeLine = issue.workingTimeline;
|
|
194
|
+
const mapWorkingTimeByAssignee: Map<string, number> = new Map();
|
|
195
|
+
for (const workingTime of workingTimeLine) {
|
|
196
|
+
const author = workingTime.author;
|
|
197
|
+
const workingMinutes = workingTime.durationMinutes;
|
|
198
|
+
if (!mapWorkingTimeByAssignee.has(author)) {
|
|
199
|
+
mapWorkingTimeByAssignee.set(author, 0);
|
|
200
|
+
}
|
|
201
|
+
const currentWorkingMinutes = mapWorkingTimeByAssignee.get(author) || 0;
|
|
202
|
+
mapWorkingTimeByAssignee.set(
|
|
203
|
+
author,
|
|
204
|
+
currentWorkingMinutes + workingMinutes,
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
return mapWorkingTimeByAssignee;
|
|
208
|
+
};
|
|
209
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Issue } from '../entities/Issue';
|
|
2
|
+
import { IssueRepository } from './adapter-interfaces/IssueRepository';
|
|
3
|
+
import { Project } from '../entities/Project';
|
|
4
|
+
|
|
5
|
+
export class ClearNextActionHourUseCase {
|
|
6
|
+
constructor(
|
|
7
|
+
readonly issueRepository: Pick<IssueRepository, 'clearProjectField'>,
|
|
8
|
+
) {}
|
|
9
|
+
|
|
10
|
+
run = async (input: {
|
|
11
|
+
targetDates: Date[];
|
|
12
|
+
project: Project;
|
|
13
|
+
issues: Issue[];
|
|
14
|
+
cacheUsed: boolean;
|
|
15
|
+
}): Promise<void> => {
|
|
16
|
+
const nextActionHour = input.project.nextActionHour;
|
|
17
|
+
if (!nextActionHour || input.cacheUsed) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const targetDates = input.targetDates
|
|
21
|
+
.filter((targetDate) => targetDate.getMinutes() === 45)
|
|
22
|
+
.reverse();
|
|
23
|
+
if (targetDates.length === 0) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const targetDate = new Date(
|
|
27
|
+
targetDates[targetDates.length - 1].getTime() + 5 * 60 * 1000,
|
|
28
|
+
);
|
|
29
|
+
const targetHour = targetDate.getHours();
|
|
30
|
+
const isTargetIssue = (issue: Issue): boolean => {
|
|
31
|
+
return (
|
|
32
|
+
issue.nextActionHour !== null &&
|
|
33
|
+
issue.nextActionHour <= targetHour &&
|
|
34
|
+
(issue.nextActionDate === null ||
|
|
35
|
+
issue.nextActionDate.getTime() <= targetDate.getTime()) &&
|
|
36
|
+
issue.state === 'OPEN'
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
for (const issue of input.issues) {
|
|
40
|
+
if (!isTargetIssue(issue)) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
await this.issueRepository.clearProjectField(
|
|
44
|
+
input.project,
|
|
45
|
+
nextActionHour.fieldId,
|
|
46
|
+
issue,
|
|
47
|
+
);
|
|
48
|
+
await new Promise((resolve) => setTimeout(resolve, 5000));
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|