修改系统概览中统计信息的显示逻辑

This commit is contained in:
PingChuan
2025-05-30 16:14:28 +08:00
parent 01cea56a6a
commit 202d64efd6
+15 -3
View File
@@ -1,3 +1,4 @@
import { log } from "node:console";
import { postgrestGet, type PostgrestParams } from "../postgrest-client";
import dayjs from 'dayjs';
@@ -171,12 +172,13 @@ export async function getHomeData(): Promise<HomeStatistics> {
// 计算同比增长
let reviewGrowthValue = 0;
let reviewGrowthIsUp = true;
// console.log('lastMonthReviewed-------', lastMonthReviewed);
// console.log('monthlyReviewedFiles-------', monthlyReviewedFiles);
if (lastMonthReviewed > 0) {
const growthRate = ((monthlyReviewedFiles - lastMonthReviewed) / lastMonthReviewed) * 100;
reviewGrowthValue = Math.abs(parseFloat(growthRate.toFixed(1)));
reviewGrowthIsUp = growthRate >= 0;
} else if (lastMonthReviewed == 0 && monthlyReviewedFiles > 0) {
reviewGrowthValue = 100;
reviewGrowthIsUp = true;
}
// 3. 审核通过率 - 本月审核通过率
@@ -223,16 +225,26 @@ export async function getHomeData(): Promise<HomeStatistics> {
? parseFloat(((lastMonthTotal / lastMonthReviewed) * 100).toFixed(1))
: 0;
console.log('上个月-------', lastMonthPassRate);
// 计算通过率同比增长
let passRateGrowthValue = 0;
let passRateGrowthIsUp = true;
if (lastMonthPassRate > 0) {
const passRateGrowth = ((monthlyPassRate - lastMonthPassRate) / lastMonthPassRate) * 100;
passRateGrowthValue = Math.abs(parseFloat(passRateGrowth.toFixed(1)));
passRateGrowthIsUp = passRateGrowth >= 0;
} else if (lastMonthPassRate == 0 && monthlyPassRate > 0) {
passRateGrowthValue = 100;
passRateGrowthIsUp = true;
}
console.log('上月通过率-------', lastMonthPassRate);
console.log('本月通过率-------', monthlyPassRate);
// 4. 检查出的问题总数(从评估结果表中统计)
const thisMonthIssuesParams: PostgrestParams = {
select: 'count',
@@ -269,12 +281,12 @@ export async function getHomeData(): Promise<HomeStatistics> {
let issuesGrowthValue = 0;
let issuesGrowthIsUp = true;
if (lastMonthIssuesCount > 0) {
const issuesGrowth = ((thisMonthIssuesCount - lastMonthIssuesCount) / lastMonthIssuesCount) * 100;
issuesGrowthValue = Math.abs(parseFloat(issuesGrowth.toFixed(1)));
issuesGrowthIsUp = issuesGrowth >= 0;
}
// 返回统计结果
return {
todayPendingFiles,