Skip to content

Commit

Permalink
feat: update
Browse files Browse the repository at this point in the history
  • Loading branch information
Allen Zhang (张涛) committed Jul 18, 2024
1 parent a864466 commit 87efc91
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 17 deletions.
6 changes: 3 additions & 3 deletions packages/canyon-backend/src/coverage/coverage.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { CoverageService } from './services/coverage.service';
import { RetrieveCoverageTreeSummaryService } from './services/retrieve-coverage-tree-summary.service';
import { PrismaService } from '../prisma/prisma.service';
import { ConsumerCoverageService } from './services/core/consumer-coverage.service';
import {CoverageReportsService} from "./services/coverage-reports.service";
import { CoverageReportsService } from './services/coverage-reports.service';

@Controller()
export class CoverageController {
Expand Down Expand Up @@ -64,8 +64,8 @@ export class CoverageController {

@Get('api/coverage/reports')
async coverageReports(@Query() query): Promise<any> {
const { bu, start,end } = query;
return this.coverageReportsService.invoke({bu, start,end })
const { bu, start, end } = query;
return this.coverageReportsService.invoke({ bu, start, end });
}

// 获取概览,重要!!!!!
Expand Down
56 changes: 42 additions & 14 deletions packages/canyon-backend/src/coverage/services/coverage.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,47 @@ export class CoverageService {
reportID: reportID === '' ? undefined : reportID,
},
});
const promise = filepath
? this.prisma.covMapTest
.findMany({
where: removeNullKeys({
projectID,
sha,
path: filepath,
}),
select: {
path: true,
mapJsonStr: true,
},
})
.then((res) => {
return res.reduce((acc, cur) => {
acc[cur.path] = JSON.parse(cur.mapJsonStr);
return acc;
}, {});
})
: this.prisma.covMapTest
.findMany({
where: removeNullKeys({
projectID,
sha,
path: filepath,
}),
select: {
path: true,
mapJsonStatementMapStartLine: true,
},
})
.then((res) => {
return res.reduce((acc, cur) => {
acc[cur.path] = {
statementMap: JSON.parse(
cur.mapJsonStatementMapStartLine || '{}',
),
};
return acc;
}, {});
});
const maps = [
this.prisma.covHit
.findFirst({
Expand All @@ -92,20 +133,7 @@ export class CoverageService {
.then((res) => {
return JSON.parse(res.mapJsonStr);
}),
this.prisma.covMapTest
.findMany({
where: removeNullKeys({
projectID,
sha,
path: filepath,
}),
})
.then((res) => {
return res.reduce((acc, cur) => {
acc[cur.path] = JSON.parse(cur.mapJsonStr);
return acc;
}, {});
}),
promise,
];

const [hit, map] = await Promise.all(maps);
Expand Down

0 comments on commit 87efc91

Please sign in to comment.