From 6fdb7de3e29264c4bfa876a8f507a664fd912cf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Allen=20Zhang=20=28=E5=BC=A0=E6=B6=9B=29?= Date: Mon, 22 Jul 2024 11:37:01 +0800 Subject: [PATCH] feat: update --- .../services/coverage-client.service.ts | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/packages/canyon-backend/src/coverage/services/coverage-client.service.ts b/packages/canyon-backend/src/coverage/services/coverage-client.service.ts index 76a5bc12..08aa333b 100755 --- a/packages/canyon-backend/src/coverage/services/coverage-client.service.ts +++ b/packages/canyon-backend/src/coverage/services/coverage-client.service.ts @@ -1,4 +1,8 @@ -import { Injectable, UnauthorizedException } from '@nestjs/common'; +import { + HttpException, + Injectable, + UnauthorizedException, +} from '@nestjs/common'; import { PrismaService } from '../../prisma/prisma.service'; import { CoverageClientDto } from '../dto/coverage-client.dto'; import { Coverage } from '@prisma/client'; @@ -53,6 +57,20 @@ export class CoverageClientService { } } + // 3.检验 project 是否存在 + const project = await this.prisma.project.findFirst({ + where: { + id: coverageClientDto.projectID, + }, + select: { + instrumentCwd: true, + }, + }); + if (!project) { + // 返回错误,项目不存在 + throw new HttpException('project not found', 400); + } + coverageClientDto.sha = coverageClientDto.commitSha; // 注意这里还是小驼峰 @@ -96,14 +114,6 @@ export class CoverageClientService { //后加的 coverage: coverageReport.coverage, }; - const project = await this.prisma.project.findFirst({ - where: { - id: cov.projectID, - }, - select: { - instrumentCwd: true, - }, - }); const dataFormatAndCheckQueueDataToBeConsumed = await this.dataFormatAndCheck(cov, project?.instrumentCwd);