chore: history projectId

This commit is contained in:
xiaojunnuo
2026-02-11 18:11:33 +08:00
parent 806a69fef3
commit 638a7f0ab4
15 changed files with 224 additions and 146 deletions
@@ -66,7 +66,8 @@ export class HistoryService extends BaseService<HistoryEntity> {
pipelineId: pipeline.id,
title: pipeline.title,
status: 'start',
triggerType
triggerType,
projectId: pipeline.projectId,
};
const { id } = await this.add(bean);
//清除大于pipeline.keepHistoryCount的历史记录
@@ -747,20 +747,35 @@ export class PipelineService extends BaseService<PipelineEntity> {
return;
}
async getProjectId(pipelineId: number) {
const pipelineEntity = await this.repository.findOne({
select: {
projectId: true,
},
where: {
id: pipelineId,
},
});
return pipelineEntity.projectId;
}
private async saveHistory(history: RunHistory) {
//修改pipeline状态
const pipelineEntity = new PipelineEntity();
let pipelineEntity = new PipelineEntity();
pipelineEntity.id = parseInt(history.pipeline.id);
pipelineEntity.status = history.pipeline.status.result + "";
pipelineEntity.lastHistoryTime = history.pipeline.status.startTime;
await this.update(pipelineEntity);
const projectId = await this.getProjectId(pipelineEntity.id);
pipelineEntity.projectId = projectId;
const entity: HistoryEntity = new HistoryEntity();
entity.id = parseInt(history.id);
entity.userId = history.pipeline.userId;
entity.status = pipelineEntity.status;
entity.pipeline = JSON.stringify(history.pipeline);
entity.pipelineId = parseInt(history.pipeline.id);
entity.projectId = pipelineEntity.projectId;
await this.historyService.save(entity);
const logEntity: HistoryLogEntity = new HistoryLogEntity();
@@ -769,6 +784,7 @@ export class PipelineService extends BaseService<PipelineEntity> {
logEntity.pipelineId = entity.pipelineId;
logEntity.historyId = entity.id;
logEntity.logs = JSON.stringify(history.logs);
logEntity.projectId = pipelineEntity.projectId;
await this.historyLogService.addOrUpdate(logEntity);
}
@@ -984,7 +1000,7 @@ export class PipelineService extends BaseService<PipelineEntity> {
throw new NeedVIPException("此功能需要升级专业版");
}
if (!userId || ids.length === 0) {
if (userId == null || ids.length === 0) {
return;
}
const where:any = {