mirror of
https://github.com/certd/certd.git
synced 2026-04-24 12:27:25 +08:00
perf(monitor): 支持查看监控执行记录
- 新增监控任务执行记录页面及相关API - 添加数据库表结构及多数据库支持 - 完善国际化翻译 - 实现批量删除功能 - 优化站点监控服务逻辑
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
|
||||
CREATE TABLE `cd_job_history`
|
||||
(
|
||||
`id` bigint PRIMARY KEY AUTO_INCREMENT NOT NULL,
|
||||
`user_id` bigint NOT NULL,
|
||||
`project_id` bigint ,
|
||||
`type` varchar(100) NOT NULL,
|
||||
`title` varchar(512) NOT NULL,
|
||||
`related_id` varchar(100),
|
||||
`result` varchar(100) NOT NULL,
|
||||
`content` longtext ,
|
||||
`start_at` bigint NOT NULL,
|
||||
`end_at` bigint ,
|
||||
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
|
||||
|
||||
CREATE INDEX `index_job_history_user_id` ON `cd_job_history` (`user_id`);
|
||||
CREATE INDEX `index_job_history_project_id` ON `cd_job_history` (`project_id`);
|
||||
CREATE INDEX `index_job_history_type` ON `cd_job_history` (`type`);
|
||||
|
||||
ALTER TABLE `cd_job_history` ENGINE = InnoDB;
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
CREATE TABLE "cd_job_history"
|
||||
(
|
||||
"id" bigint PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY NOT NULL,
|
||||
"user_id" bigint NOT NULL,
|
||||
"project_id" bigint ,
|
||||
"type" varchar(100) NOT NULL,
|
||||
"title" varchar(512) NOT NULL,
|
||||
"related_id" varchar(100),
|
||||
"result" varchar(100) NOT NULL,
|
||||
"content" text ,
|
||||
"start_at" bigint NOT NULL,
|
||||
"end_at" bigint ,
|
||||
"create_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
||||
"update_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP)
|
||||
);
|
||||
|
||||
|
||||
|
||||
CREATE INDEX "index_job_history_user_id" ON "cd_job_history" ("user_id");
|
||||
CREATE INDEX "index_job_history_project_id" ON "cd_job_history" ("project_id");
|
||||
CREATE INDEX "index_job_history_type" ON "cd_job_history" ("type");
|
||||
@@ -3,7 +3,7 @@ CREATE TABLE "cd_job_history"
|
||||
(
|
||||
"id" integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
"user_id" integer NOT NULL,
|
||||
"project_id" integer NOT NULL,
|
||||
"project_id" integer ,
|
||||
"type" varchar(100) NOT NULL,
|
||||
"title" varchar(512) NOT NULL,
|
||||
"related_id" varchar(100),
|
||||
|
||||
@@ -45,7 +45,6 @@ export class JobHistoryController extends CrudController<JobHistoryService> {
|
||||
return await super.list(body);
|
||||
}
|
||||
|
||||
|
||||
@Post('/info', { description: Constants.per.authOnly, summary: "查询监控运行历史详情" })
|
||||
async info(@Query('id') id: number) {
|
||||
await this.checkOwner(this.service,id,"read");
|
||||
@@ -55,8 +54,12 @@ export class JobHistoryController extends CrudController<JobHistoryService> {
|
||||
@Post('/delete', { description: Constants.per.authOnly, summary: "删除监控运行历史" })
|
||||
async delete(@Query('id') id: number) {
|
||||
await this.checkOwner(this.service,id,"write");
|
||||
const res = await super.delete(id);
|
||||
return res
|
||||
return await super.delete(id);
|
||||
}
|
||||
@Post('/batchDelete', { description: Constants.per.authOnly, summary: "批量删除监控运行历史" })
|
||||
async batchDelete(@Body('ids') ids: number[]) {
|
||||
const { projectId, userId } = await this.getProjectUserIdWrite()
|
||||
await this.service.batchDelete(ids,userId,projectId);
|
||||
return this.ok();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -357,10 +357,11 @@ export class SiteInfoService extends BaseService<SiteInfoEntity> {
|
||||
if (userId==null) {
|
||||
throw new Error("userId is required");
|
||||
}
|
||||
const sites = await this.repository.find({
|
||||
where: {userId,projectId}
|
||||
});
|
||||
this.checkList(sites,false);
|
||||
// const sites = await this.repository.find({
|
||||
// where: {userId,projectId}
|
||||
// });
|
||||
// this.checkList(sites,false);
|
||||
await this.triggerJobOnce(userId,projectId);
|
||||
}
|
||||
|
||||
async checkList(sites: SiteInfoEntity[],isCommon: boolean) {
|
||||
@@ -529,7 +530,7 @@ export class SiteInfoService extends BaseService<SiteInfoEntity> {
|
||||
}
|
||||
//判断是否已关闭
|
||||
const setting = await this.userSettingsService.getSetting<UserSiteMonitorSetting>(userId,projectId, UserSiteMonitorSetting);
|
||||
if (!setting.cron) {
|
||||
if (setting && !setting.cron) {
|
||||
return;
|
||||
}
|
||||
jobEntity = {
|
||||
|
||||
Reference in New Issue
Block a user