From bc36b6f386385387de54d3fb4b01423fe30d9e53 Mon Sep 17 00:00:00 2001 From: zhaoyingbo Date: Mon, 11 Mar 2024 01:50:17 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E5=AE=B9=E9=94=99?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/manageRobot/index.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/controllers/manageRobot/index.ts b/controllers/manageRobot/index.ts index ad07a92..6812564 100644 --- a/controllers/manageRobot/index.ts +++ b/controllers/manageRobot/index.ts @@ -32,20 +32,20 @@ const getStatisticsInfo = async () => { getPrevWeekWithYear() ); return { - total_count: String(curWeekInfo.total_count), + total_count: String(curWeekInfo?.total_count ?? 0), weekly_count_rate: calculateWeeklyRate( - curWeekInfo.total_count, - prevWeekInfo.total_count + curWeekInfo?.total_count ?? 0, + prevWeekInfo?.total_count ?? 0 ).text, - duration: String(curWeekInfo.duration), + duration: String(curWeekInfo?.duration ?? 0), weekly_duration_rate: calculateWeeklyRate( - curWeekInfo.duration, - prevWeekInfo.duration + curWeekInfo?.duration ?? 0, + prevWeekInfo?.duration ?? 0 ).text, - success_rate: String(curWeekInfo.success_rate), + success_rate: String(curWeekInfo?.success_rate), weekly_success_rate: calculateWeeklyRate( - curWeekInfo.success_rate, - prevWeekInfo.success_rate + curWeekInfo?.success_rate, + prevWeekInfo?.success_rate ).text, }; }; @@ -53,10 +53,10 @@ const getStatisticsInfo = async () => { const getProjDiffInfo = async () => { const curWeekInfo = await db.view.getProjStatisticsByWeek( getWeekTimeWithYear() - ); + ) || []; const prevWeekInfo = await db.view.getProjStatisticsByWeek( getPrevWeekWithYear() - ); + ) || []; const group: { project_name: string;