|
|
@@ -503,32 +503,21 @@ $chartSvg = $buildDualChartsHtml($curDaily, $prevDaily);
|
|
|
// ============================================================
|
|
|
// 1 月 6 日起每日学案量点状图
|
|
|
// ============================================================
|
|
|
-$cumulativeEnd = $endCurrent->copy();
|
|
|
+$jan6 = $todayStart->copy()->setDate(2026, 1, 6);
|
|
|
+$totalCumDays = (int) $jan6->diffInDays($todayStart) + 1;
|
|
|
|
|
|
-$dailyRows = $db::select(
|
|
|
- "SELECT DATE(created_at) AS d, COUNT(*) AS c FROM papers WHERE teacher_id IS NOT NULL AND teacher_id != '' AND created_at >= '2026-01-06 00:00:00' AND created_at < ? GROUP BY DATE(created_at) ORDER BY d",
|
|
|
- [$cumulativeEnd->format('Y-m-d H:i:s')]
|
|
|
-);
|
|
|
-
|
|
|
-$dailyMap = [];
|
|
|
-$firstDate = '2026-01-06';
|
|
|
-$lastDate = $cumulativeEnd->format('Y-m-d');
|
|
|
-foreach ($dailyRows as $row) {
|
|
|
- $dailyMap[$row->d] = (int) $row->c;
|
|
|
- if ($row->d < $firstDate) { $firstDate = $row->d; }
|
|
|
- if ($row->d > $lastDate) { $lastDate = $row->d; }
|
|
|
-}
|
|
|
-
|
|
|
-// 直接按日期字符串迭代,避免 Carbon 时区问题
|
|
|
$dotLabels = [];
|
|
|
$dotValues = [];
|
|
|
-$iterDate = new \DateTime($firstDate);
|
|
|
-$endDate = new \DateTime($lastDate);
|
|
|
-while ($iterDate <= $endDate) {
|
|
|
- $key = $iterDate->format('Y-m-d');
|
|
|
- $dotLabels[] = $iterDate->format('m/d');
|
|
|
- $dotValues[] = $dailyMap[$key] ?? 0;
|
|
|
- $iterDate->modify('+1 day');
|
|
|
+for ($i = 0; $i < $totalCumDays; $i++) {
|
|
|
+ $dayStart = $jan6->copy()->addDays($i);
|
|
|
+ $dayEnd = $dayStart->copy()->addDay();
|
|
|
+ $dotLabels[] = $dayStart->format('m/d');
|
|
|
+ $dotValues[] = (int) $db::table('papers')
|
|
|
+ ->whereNotNull('teacher_id')
|
|
|
+ ->where('teacher_id', '!=', '')
|
|
|
+ ->where('created_at', '>=', $dayStart)
|
|
|
+ ->where('created_at', '<', $dayEnd)
|
|
|
+ ->count();
|
|
|
}
|
|
|
$totalDays = count($dotValues);
|
|
|
$cumulativeTotal = array_sum($dotValues);
|