Skip to content

Commit

Permalink
feat: update
Browse files Browse the repository at this point in the history
  • Loading branch information
Allen Zhang (张涛) committed May 7, 2024
1 parent 46f36a7 commit 58944fa
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 28 deletions.
13 changes: 9 additions & 4 deletions packages/canyon-backend/src/coverage/coverage.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,19 @@ export class CoverageController {

@Get('api/coverage/summary/map')
async coverageSummary(@Query() query): Promise<any> {
const { sha, reportID } = query;
return this.coverageService.getCoverageSummaryMap(sha, reportID);
const { projectID, sha, reportID } = query;
return this.coverageService.getCoverageSummaryMap(projectID, sha, reportID);
}

@Get('api/coverage/map')
async coveragemMap(@Query() query): Promise<any> {
const { sha, reportID, filepath } = query;
return this.coverageService.getCoverageData(sha, reportID, filepath);
const { projectID, sha, reportID, filepath } = query;
return this.coverageService.getCoverageData(
projectID,
sha,
reportID,
filepath,
);
}

// 获取概览,重要!!!!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ export class CoverageService {
) {}

async getCoverageSummaryMap(
projectID,
sha: string,
reportID: string,
): Promise<CoverageSummary[]> {
const coverages = await this.prisma.coverage.findMany({
where: {
sha: sha,
projectID,
covType: 'agg',
},
orderBy: {
Expand All @@ -30,6 +32,7 @@ export class CoverageService {
return [];
}
const coverageData = await this.getCoverageDataFromAdapter(
projectID,
sha,
reportID,
).then((r) => this.testExcludeService.invoke(coverages[0].projectID, r));
Expand All @@ -49,18 +52,20 @@ export class CoverageService {
});
}

async getCoverageData(commitSha, reportID, filepath) {
async getCoverageData(projectID, commitSha, reportID, filepath) {
const coverageData = await this.getCoverageDataFromAdapter(
projectID,
commitSha,
reportID,
);
return JSON.stringify(coverageData[filepath]);
}

// 私有方法
private async getCoverageDataFromAdapter(sha, reportID) {
private async getCoverageDataFromAdapter(projectID, sha, reportID) {
const { relationID } = await this.prisma.coverage.findFirst({
where: {
projectID,
sha: sha,
covType: reportID === '' ? 'all' : 'agg',
reportID: reportID === '' ? undefined : reportID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const Sha = () => {
const { data: coverageSummaryMapData, loading } = useRequest(
() =>
getCoverageSummaryMapService({
projectID: prm.id as string,
reportID: sprm.get('report_id'),
sha: prm.sha,
}),
Expand Down Expand Up @@ -60,16 +61,15 @@ const Sha = () => {
projectID: prm.id || '',
mode: sprm.get('mode') || '',
}).then((r) => {
if (r.fileCoverage){
if (r.fileCoverage) {
// console.log(r)
setMainData(r);
} else {
setMainData(false)
setMainData(false);
}

});
} else {
console.log('设么也不做');
// console.log('设么也不做');
setMainData(false);
}
}, [activatedPath]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export function handleSelectFile({ projectID, sha, filepath, reportID }: HandleS
const fileCoverageRequest = axios
.get(`/api/coverage/map`, {
params: {
projectID,
reportID: reportID,
sha: sha,
filepath: filepath,
Expand Down Expand Up @@ -55,22 +56,23 @@ export function handleSelectFile({ projectID, sha, filepath, reportID }: HandleS
);
}


export const getCoverageSummaryMapService = ({sha,reportID})=>axios({
url: '/api/coverage/summary/map',
method: 'GET',
params: {
reportID: reportID || '',
sha: sha || ''
},
})
.then(({ data }) => data)
.then((r) =>
r.map((i) => ({
...i,
path: i.path.replace('~/', ''),
})),
)
.then((r) => {
return r;
export const getCoverageSummaryMapService = ({ projectID, sha, reportID }) =>
axios({
url: '/api/coverage/summary/map',
method: 'GET',
params: {
reportID: reportID || '',
sha: sha || '',
projectID: projectID || '',
},
})
.then(({ data }) => data)
.then((r) =>
r.map((i) => ({
...i,
path: i.path.replace('~/', ''),
})),
)
.then((r) => {
return r;
});
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const BasicForms: FC<{ data: any }> = ({ data }) => {
tag: values.tag,
description: values.description,
defaultBranch: '__null__',
rules:[]
},
}).then(() => {
message.success('成功');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ const ProjectConfigure = () => {
defaultBranch ||
GetProjectByIdDocumentData?.getProjectByID.defaultBranch ||
'-',
rules: [],
},
}).then(() => {
showMessage();
Expand Down

0 comments on commit 58944fa

Please sign in to comment.