Skip to content

Commit

Permalink
feat: update
Browse files Browse the repository at this point in the history
  • Loading branch information
Allen Zhang (张涛) committed Feb 20, 2024
1 parent c6b5e7a commit 677ad71
Showing 1 changed file with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,35 @@ export class GetProjectCompartmentDataService {
lastCoverageSummary.covered,
lastCoverageSummary.total,
);
// 获取 30 天前的日期
const thirtyDaysAgo = new Date();
thirtyDaysAgo.setDate(thirtyDaysAgo.getDate() - 30);

// 上报的最大值
const maxs = coverages.map((coverage) => {
const summary = summarys.find(
(item) => item.sha === coverage.sha && item.metricType === 'statements',
);
const max =
(summary?.total || 0) === 0
? 0
: percent(summary.covered, summary.total);
return max;
});
const maxs = coverages
.filter((i) => new Date(i.createdAt) >= thirtyDaysAgo)
.map((coverage) => {
const summary = summarys.find(
(item) =>
item.sha === coverage.sha && item.metricType === 'statements',
);
const max =
(summary?.total || 0) === 0
? 0
: percent(summary.covered, summary.total);
return max;
});

const max = Math.max(...maxs);

console.log(max > 0, 'max');
return [
{
label: 'projects.total_times',
value: String(coverages.length),
},
{
label: 'projects.max_coverage',
value: max.toFixed(2) + '%',
value: max > 0 ? max.toFixed(2) + '%' : '0%',
},
{
label: 'projects.latest_report_time',
Expand Down

0 comments on commit 677ad71

Please sign in to comment.