-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Allen Zhang (张涛)
committed
Apr 10, 2024
1 parent
0c3b46f
commit 0a2c196
Showing
4 changed files
with
57 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
packages/canyon-backend/src/coverage/services/test.coverage.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { PrismaService } from '../../prisma/prisma.service'; | ||
import { CoverageDataAdapterService } from './coverage-data-adapter.service'; | ||
import { PullChangeCodeAndInsertDbService } from './pull-change-code-and-insert-db.service'; | ||
import { CoveragediskService } from './coveragedisk.service'; | ||
import { | ||
genSummaryMapByCoverageMap, | ||
getSummaryByPath, | ||
mergeCoverageMap, | ||
} from '@canyon/data'; | ||
|
||
@Injectable() | ||
export class TestCoverage { | ||
constructor( | ||
private readonly prisma: PrismaService, | ||
private readonly coverageDataAdapterService: CoverageDataAdapterService, | ||
private readonly pullChangeCodeAndInsertDbService: PullChangeCodeAndInsertDbService, | ||
private readonly coveragediskService: CoveragediskService, | ||
) {} | ||
|
||
async invoke() { | ||
const coverages = await this.prisma.coverage.findMany({ | ||
where: { | ||
sha: 'b61375c962499fe448a7985b22c9c7f6b1f023ea', | ||
covType: 'agg', | ||
}, | ||
}); | ||
let cov = {}; | ||
for (let i = 0; i < coverages.length; i++) { | ||
console.log(i); | ||
const c = await this.coverageDataAdapterService.retrieve( | ||
coverages[i].relationID, | ||
); | ||
cov = mergeCoverageMap(cov, c); | ||
console.log( | ||
coverages[i].reportID, | ||
getSummaryByPath('~', genSummaryMapByCoverageMap(c, []))['statements'][ | ||
'pct' | ||
], | ||
); | ||
} | ||
console.log( | ||
getSummaryByPath('~', genSummaryMapByCoverageMap(cov, []))['statements'][ | ||
'pct' | ||
], | ||
); | ||
} | ||
} |