diff --git a/packages/canyon-backend/src/coverage/coverage.module.ts b/packages/canyon-backend/src/coverage/coverage.module.ts index a44ce434..dddb8271 100644 --- a/packages/canyon-backend/src/coverage/coverage.module.ts +++ b/packages/canyon-backend/src/coverage/coverage.module.ts @@ -5,6 +5,7 @@ import { CoverageResolver } from './coverage.resolver'; import { CoverageService } from './services/coverage.service'; import { ProjectOverviewService } from './services/project-overview.service'; import { DashboardService } from './services/dashboard.service'; +import { CoverageClientService } from './services/coverage-client.service'; @Module({ imports: [PrismaModule], @@ -14,6 +15,7 @@ import { DashboardService } from './services/dashboard.service'; CoverageService, ProjectOverviewService, DashboardService, + CoverageClientService, ], exports: [], }) 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 002432dc..8662ae03 100644 --- a/packages/canyon-backend/src/coverage/services/coverage-client.service.ts +++ b/packages/canyon-backend/src/coverage/services/coverage-client.service.ts @@ -14,6 +14,14 @@ import CanyonUtil from 'canyon-util'; // 改版完以后,不能在没有创建之前上传覆盖率,并且上传完覆盖率以后需要手动触发生成报告 +function checkUserID(id) { + if (isNaN(Number(id))) { + return -1; + } else { + return Number(id); + } +} + @Injectable() export class CoverageClientService { constructor(private readonly prisma: PrismaService) {} @@ -22,7 +30,7 @@ export class CoverageClientService { // 1.检验 user 是否存在 const currentUserDb = await this.prisma.user.findFirst({ where: { - id: currentUser, + id: checkUserID(currentUser), }, }); if (!currentUserDb) { @@ -80,6 +88,7 @@ export class CoverageClientService { // ****************************************************** const coverageDataRepositoryInsertResult = await createNewCoverageData(coverage); + console.log(coverageDataRepositoryInsertResult); const coverageDataInsertDb = { compareTarget, commitSha, @@ -88,7 +97,7 @@ export class CoverageClientService { instrumentCwd, reportID, covType: 'normal', - relationID: String(coverageDataRepositoryInsertResult._id), + relationID: String(coverageDataRepositoryInsertResult.insertedId), key: coverageClientDto.key, }; const coverageInsertDbTimeStart = new Date().getTime(); @@ -103,7 +112,7 @@ export class CoverageClientService { return { msg: 'ok', coverageId: String(coverageRepositoryInsertResult.id), - coverageDataId: String(coverageDataRepositoryInsertResult._id), + coverageDataId: String(coverageDataRepositoryInsertResult.insertedId), dataFormatAndCheckTime: dataFormatAndCheckTimeEnd - dataFormatAndCheckTimeStart, coverageInsertDbTime: coverageInsertDbTimeEnd - coverageInsertDbTimeStart,