Skip to content

Commit

Permalink
feat: init
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangtao25 committed Nov 8, 2023
1 parent 57bb9d4 commit 24dc93b
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 31 deletions.
43 changes: 18 additions & 25 deletions packages/canyon-backend/src/coverage/services/coverage.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,43 +133,36 @@ export class CoverageService {
commitSha: string,
reportID: string,
): Promise<CoverageSummary[]> {
const coverage = await this.prisma.coverage.findFirst({
where: {
commitSha: commitSha,
reportID: reportID,
covType: 'agg',
},
});
//
// const codechange = await this.prisma.codechange.findFirst({
// where: {
// commitSha: commitSha,
// },
// });
let coverage: any = {};

// const coverage = axios('', { relationID: cov.relationID });
if (reportID === '') {
coverage = await this.prisma.coverage.findFirst({
where: {
commitSha: commitSha,
covType: 'all',
},
});
} else {
coverage = await this.prisma.coverage.findFirst({
where: {
commitSha: commitSha,
reportID: reportID,
covType: 'agg',
},
});
}

// TODO 实现 S3 存储服务,覆盖率实体数据的 crud
// console.log(coverage.relationID)
const coverageData = await getSpecificCoverageData(coverage.relationID);

const covSummary = genSummaryMapByCoverageMap(coverageData, []);

// console.log(await createNewCoverageData({ path: '123' }));
// console.log(await getSpecificCoverageData(coverage.relationID));
// TODO 细节实现

return Object.entries(covSummary).map(([key, value]) => {
return {
path: key,
...value,
};
});
// return this.prisma.coverage.findMany({
// where: {
// commitSha: commitSha,
// reportID: reportID,
// covType: 'all',
// },
// });
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
query GetCoverageSummaryMap($reportID: String!, $commitSha: String!) {
getCoverageSummaryMap(
reportID: $reportID
commitSha: $commitSha
) {
path
statements {
total
covered
skipped
pct
}
lines {
total
covered
skipped
pct
}
functions {
total
covered
skipped
pct
}
branches {
total
covered
skipped
pct
}
}
}
27 changes: 21 additions & 6 deletions packages/canyon-platform/src/pages/project/[id]/commits/[sha].tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
// import 'highlight.js/styles/idea.css';

import { useQuery } from '@apollo/client';
import { init } from '@canyon/report';
import { useEffect, useRef } from 'react';
import { useParams } from 'react-router';
import { useSearchParams } from 'react-router-dom';

import { GetCoverageSummaryMapDocument } from '../../../../helpers/backend/gen/graphql.ts';
const Sha = () => {
const prm = useParams();
const [sprm] = useSearchParams();
const { data } = useQuery(GetCoverageSummaryMapDocument, {
variables: {
reportID: sprm.get('report_id') || '',
commitSha: prm.sha || '',
},
});
const reportRef = useRef(null);
useEffect(() => {
if (reportRef.current) {
if (reportRef.current && data) {
const report = init(
reportRef.current,
{
Expand All @@ -14,16 +25,20 @@ const Sha = () => {
return new Promise((resolve) => {
resolve({
fileContent: '',
fileCoverage: 'asf',
fileCoverage: '',
});
});
},
},
[],
);
report.setOption({ summary: JSON.parse({}) });
const summary = data.getCoverageSummaryMap.reduce((acc, cur) => {
acc[cur.path] = cur;
return acc;
}, {});
report.setOption({ summary: summary });
}
}, []);
}, [data]);

return (
<div className='bg-white ' style={{ minHeight: 'calc(100vh - 96px)' }}>
Expand Down

0 comments on commit 24dc93b

Please sign in to comment.