From 1953b51a16a4a8b7dd5806f0a13609dc35e23a4e Mon Sep 17 00:00:00 2001 From: Yvette Carlisle Date: Sat, 23 May 2026 23:47:00 +0800 Subject: [PATCH] {"schema":"decodex/commit/1","summary":"Use daily average for missing day delta baseline","authority":"manual"} --- .../Sources/DecodexApp/AccountPanelView.swift | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/decodex-app/Sources/DecodexApp/AccountPanelView.swift b/apps/decodex-app/Sources/DecodexApp/AccountPanelView.swift index 089fd9b4..38dd39ae 100644 --- a/apps/decodex-app/Sources/DecodexApp/AccountPanelView.swift +++ b/apps/decodex-app/Sources/DecodexApp/AccountPanelView.swift @@ -1105,14 +1105,20 @@ struct AccountPoolUsageEstimateView: View { .map(\.date) .max() guard let latestDate else { - return estimate.totalUsedOfCapacityPercent + return estimate.averageDailyPoolPercent } guard let previousDate = previousUsageDate(before: latestDate) else { - return estimate.totalUsedOfCapacityPercent + return estimate.averageDailyPoolPercent } - let previousUsedPercent = measuredAccounts.reduce(0) { total, account in - total + (usageRecord(for: account, on: previousDate)?.usedPercent ?? 0) + let previousRecords = measuredAccounts.compactMap { account in + usageRecord(for: account, on: previousDate) + } + guard previousRecords.count == measuredAccounts.count else { + return estimate.averageDailyPoolPercent + } + let previousUsedPercent = previousRecords.reduce(0) { total, record in + total + record.usedPercent } let previousPoolPercent = (Double(previousUsedPercent) / Double(estimate.totalCapacityPercent)) * 100