feat: publish mileage assessment freshness
This commit is contained in:
@@ -13,6 +13,7 @@ import type { TargetSummary, TargetVehicle, TargetYearlyAssessment, TrendPoint }
|
||||
import { fetchTargets, fetchTargetVehicles, fetchTrend } from './api';
|
||||
import Blur from '../../components/Blur';
|
||||
import { weightedCompletionRate } from '../../shared/analytics/metrics';
|
||||
import { formatMileageSnapshotDateTime } from './data-freshness';
|
||||
import MileageAttributionView from './MileageAttributionView';
|
||||
import {
|
||||
filterAttributionVehicles,
|
||||
@@ -30,11 +31,6 @@ function getDefaultDate(): string {
|
||||
return `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}`;
|
||||
}
|
||||
|
||||
function getCurrentDateLabel(): string {
|
||||
const now = new Date();
|
||||
return `${now.getFullYear()}.${now.getMonth() + 1}.${now.getDate()}`;
|
||||
}
|
||||
|
||||
function fmtKm(value: number): string {
|
||||
if (value >= 10000) return (value / 10000).toFixed(2) + '万';
|
||||
return value.toLocaleString();
|
||||
@@ -53,12 +49,6 @@ function resolveAssessmentYear(target: TargetSummary, requestedYear?: number): n
|
||||
return getTargetAssessment(target, requestedYear)?.yearNumber;
|
||||
}
|
||||
|
||||
function fmtDateLabel(date: string | null): string {
|
||||
if (!date) return '';
|
||||
const [year, month, day] = date.split('-');
|
||||
return `${year}.${Number(month)}.${Number(day)}`;
|
||||
}
|
||||
|
||||
function shortTargetName(name: string): string {
|
||||
// Extract the number and a short description
|
||||
const match = name.match(/(\d+)[辆台](.+)/);
|
||||
@@ -74,7 +64,6 @@ function shortTargetName(name: string): string {
|
||||
}
|
||||
|
||||
export default function StatisticsView() {
|
||||
const currentDateLabel = getCurrentDateLabel();
|
||||
const [drillContext, setDrillContext] = useState<MileageDrillContext>(() => (
|
||||
parseMileageDrillContext(window.location.search)
|
||||
));
|
||||
@@ -642,7 +631,7 @@ export default function StatisticsView() {
|
||||
<p className="text-[8px] font-bold text-slate-400 uppercase tracking-wider">{assessment.label}已完成</p>
|
||||
<p className="text-[10px] font-black text-emerald-600">{fmtKm(assessment.completed)} km</p>
|
||||
<p className="text-[8px] font-bold text-slate-300">
|
||||
数据截至 {assessment.daysLeft === 0 ? fmtDateLabel(assessment.endDate) : currentDateLabel}
|
||||
数据截至 {formatMileageSnapshotDateTime(target.snapshotUpdatedAt)}
|
||||
</p>
|
||||
</div>
|
||||
<div className="space-y-0.5">
|
||||
|
||||
Reference in New Issue
Block a user