@chevre/domain 25.2.0-alpha.36 → 25.2.0-alpha.39
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.
|
@@ -5,11 +5,9 @@ export interface ILineNotifyMessage {
|
|
|
5
5
|
subject: string;
|
|
6
6
|
content: string;
|
|
7
7
|
}
|
|
8
|
-
export declare function task2lineNotify(params: {
|
|
9
|
-
task: factory.task.ITask<factory.taskName>;
|
|
10
|
-
}): ILineNotifyMessage;
|
|
11
8
|
export declare function tasks2lineNotify(params: {
|
|
12
|
-
tasks: factory.task.ITask<factory.taskName>[];
|
|
9
|
+
tasks: Pick<factory.task.ITask<factory.taskName>, 'id' | 'executionResults' | 'project' | 'name' | 'runsAt'>[];
|
|
10
|
+
limit: number;
|
|
13
11
|
}): ILineNotifyMessage;
|
|
14
12
|
export declare function createSendEmailMessageRecipe(params: {
|
|
15
13
|
mailData?: MailData;
|
|
@@ -4,37 +4,39 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ABORT_REPORT_SUBJECT = void 0;
|
|
7
|
-
exports.task2lineNotify = task2lineNotify;
|
|
8
7
|
exports.tasks2lineNotify = tasks2lineNotify;
|
|
9
8
|
exports.createSendEmailMessageRecipe = createSendEmailMessageRecipe;
|
|
10
9
|
const moment_1 = __importDefault(require("moment"));
|
|
11
10
|
const factory_1 = require("../../factory");
|
|
12
11
|
exports.ABORT_REPORT_SUBJECT = 'tasks aborted';
|
|
13
|
-
function task2lineNotify(params
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
12
|
+
// function task2lineNotify(params: {
|
|
13
|
+
// task: factory.task.ITask<factory.taskName>;
|
|
14
|
+
// }): ILineNotifyMessage {
|
|
15
|
+
// const task = params.task;
|
|
16
|
+
// const lastExecutionResult = (task.executionResults.length > 0) ? task.executionResults.slice(-1)[0] : undefined;
|
|
17
|
+
// let lastError = lastExecutionResult?.error;
|
|
18
|
+
// if (typeof lastError === 'string') {
|
|
19
|
+
// lastError = { message: lastError, name: 'Error' };
|
|
20
|
+
// }
|
|
21
|
+
// const lastMessage = `${String(lastError?.name)} ${String(lastError?.message)}`;
|
|
22
|
+
// const content = `project:${task.project?.id}
|
|
23
|
+
// id:${task.id}
|
|
24
|
+
// name:${task.name}
|
|
25
|
+
// runsAt:${moment(task.runsAt)
|
|
26
|
+
// .toISOString()}
|
|
27
|
+
// lastTriedAt:${moment((task.lastTriedAt as Date))
|
|
28
|
+
// .toISOString()}
|
|
29
|
+
// numberOfTried:${task.numberOfTried}
|
|
30
|
+
// lastMessage:${lastMessage}`;
|
|
31
|
+
// return {
|
|
32
|
+
// subject: ABORT_REPORT_SUBJECT,
|
|
33
|
+
// content: content
|
|
34
|
+
// };
|
|
35
|
+
// }
|
|
35
36
|
const MAX_LAST_MESSAGE_LENGTH = 60;
|
|
36
37
|
function tasks2lineNotify(params) {
|
|
37
|
-
const
|
|
38
|
+
const abortedTasksCount = (params.tasks.length >= params.limit) ? `over ${params.tasks.length}` : params.tasks.length;
|
|
39
|
+
const subject = `${abortedTasksCount} ${exports.ABORT_REPORT_SUBJECT}`;
|
|
38
40
|
let content;
|
|
39
41
|
// あまりに通知タスク数が多いケースに対応
|
|
40
42
|
if (params.tasks.length > 10) {
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import type { TaskRepo } from '../../repo/task';
|
|
2
2
|
import type { IntegrationSettingRepo } from '../../repo/setting/integration';
|
|
3
|
+
interface INotifyAbortedTasksRepos {
|
|
4
|
+
task: TaskRepo;
|
|
5
|
+
integrationSetting: IntegrationSettingRepo;
|
|
6
|
+
}
|
|
3
7
|
/**
|
|
4
8
|
* 中止されたタスクリストをEメールで通知する
|
|
5
9
|
* add(2025-03-13~)
|
|
6
10
|
*/
|
|
7
11
|
declare function notifyAbortedTasksByEmail(params: {
|
|
8
12
|
dateAbortedGte: Date;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
dateAbortedLte: Date;
|
|
14
|
+
/**
|
|
15
|
+
* 中止タスクがあまりに多いと性能に影響するので、現実的にタスク数を制限する
|
|
16
|
+
*/
|
|
17
|
+
limit: number;
|
|
18
|
+
}): (repos: INotifyAbortedTasksRepos) => Promise<void>;
|
|
19
|
+
export { notifyAbortedTasksByEmail, INotifyAbortedTasksRepos };
|
|
@@ -17,16 +17,24 @@ function notifyAbortedTasksByEmail(params) {
|
|
|
17
17
|
return async (repos) => {
|
|
18
18
|
const abortedTasksWithoutReport = await repos.integrationSetting.getByKey('abortedTasksWithoutReport');
|
|
19
19
|
const abortedTasks = await repos.task.projectFields({
|
|
20
|
+
limit: params.limit,
|
|
21
|
+
page: 1,
|
|
20
22
|
status: { $eq: factory_1.factory.taskStatus.Aborted },
|
|
21
|
-
dateAborted: {
|
|
23
|
+
dateAborted: {
|
|
24
|
+
$gte: params.dateAbortedGte,
|
|
25
|
+
$lte: params.dateAbortedLte,
|
|
26
|
+
},
|
|
22
27
|
// 中止を報告しないタスク以外にフィルター
|
|
23
28
|
...(abortedTasksWithoutReport.length > 0)
|
|
24
29
|
? { name: { $nin: abortedTasksWithoutReport } }
|
|
25
30
|
: undefined
|
|
26
|
-
}, []);
|
|
31
|
+
}, ['executionResults', 'name', 'project', 'runsAt']);
|
|
27
32
|
if (abortedTasks.length > 0) {
|
|
28
33
|
// 開発者へ報告
|
|
29
|
-
const message = (0, factory_2.tasks2lineNotify)({
|
|
34
|
+
const message = (0, factory_2.tasks2lineNotify)({
|
|
35
|
+
tasks: abortedTasks,
|
|
36
|
+
limit: params.limit
|
|
37
|
+
});
|
|
30
38
|
const notifyResult = await (0, notifyByEmail_1.notifyByEmail)({
|
|
31
39
|
subject: message.subject, content: message.content,
|
|
32
40
|
logLevel: 'error'
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.1090.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.1090.0",
|
|
14
|
-
"@chevre/factory": "10.0.0-alpha.
|
|
14
|
+
"@chevre/factory": "10.0.0-alpha.1",
|
|
15
15
|
"@motionpicture/coa-service": "10.0.0",
|
|
16
16
|
"@motionpicture/gmo-service": "6.1.0-alpha.0",
|
|
17
17
|
"@sendgrid/client": "8.1.4",
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"postversion": "git push origin --tags",
|
|
89
89
|
"prepublishOnly": "npm run clean && npm run build"
|
|
90
90
|
},
|
|
91
|
-
"version": "25.2.0-alpha.
|
|
91
|
+
"version": "25.2.0-alpha.39"
|
|
92
92
|
}
|