-
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
1 parent
8b88304
commit 8493e24
Showing
5 changed files
with
61 additions
and
1 deletion.
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
41 changes: 41 additions & 0 deletions
41
packages/canyon-backend/src/cov/services/coverage.service.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,41 @@ | ||
import { HttpException, Injectable } from "@nestjs/common"; | ||
import { PrismaService } from "src/prisma/prisma.service"; | ||
import { CoverageSummaryDataMap } from "canyon-data"; | ||
import { decompressedData } from "../../utils/zstd"; | ||
|
||
@Injectable() | ||
export class CoverageService { | ||
constructor(private readonly prisma: PrismaService) {} | ||
|
||
async coverageSummaryMap(projectID, sha: string, reportID: string) { | ||
const coverage = await this.prisma.coverage.findFirst({ | ||
where: { | ||
sha, | ||
projectID, | ||
reportID: reportID, | ||
covType: reportID ? "agg" : "all", | ||
}, | ||
}); | ||
|
||
if (coverage?.summary) { | ||
return decompressedData<CoverageSummaryDataMap>( | ||
coverage.summary, | ||
).then((data) => { | ||
return Object.entries(data).map(([key, value]) => { | ||
return { | ||
...value, | ||
path: key, | ||
}; | ||
}); | ||
}); | ||
} | ||
throw new HttpException( | ||
{ | ||
statusCode: 404, | ||
message: "summary data not found", | ||
errorCode: "SUMMARY_DATA_NOT_FOUND", | ||
}, | ||
404, | ||
); | ||
} | ||
} |
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