Skip to content

Commit

Permalink
feat: update
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangtao25 committed Nov 13, 2023
1 parent a1bffd0 commit db12199
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions packages/canyon-backend/src/coverage/coverage.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -14,6 +15,7 @@ import { DashboardService } from './services/dashboard.service';
CoverageService,
ProjectOverviewService,
DashboardService,
CoverageClientService,
],
exports: [],
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand All @@ -22,7 +30,7 @@ export class CoverageClientService {
// 1.检验 user 是否存在
const currentUserDb = await this.prisma.user.findFirst({
where: {
id: currentUser,
id: checkUserID(currentUser),
},
});
if (!currentUserDb) {
Expand Down Expand Up @@ -80,6 +88,7 @@ export class CoverageClientService {
// ******************************************************
const coverageDataRepositoryInsertResult =
await createNewCoverageData(coverage);
console.log(coverageDataRepositoryInsertResult);
const coverageDataInsertDb = {
compareTarget,
commitSha,
Expand All @@ -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();
Expand All @@ -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,
Expand Down

0 comments on commit db12199

Please sign in to comment.