fix: Reading stats UI (#2322)

* part1 fix: reading days show duration

* part2 fix: Fix time formatting in favorite days chart

---------

Co-authored-by: WorldTeacher <coding_contact@pm.me>
This commit is contained in:
WorldTeacher
2026-01-18 14:10:04 -07:00
committed by GitHub
co-authored by WorldTeacher
parent ecdb58c11f
commit 6338ed13fc
2 changed files with 3 additions and 3 deletions
@@ -84,7 +84,7 @@ public interface ReadingSessionRepository extends JpaRepository<ReadingSessionEn
SELECT
DAYOFWEEK(rs.startTime) as dayOfWeek,
COUNT(rs) as sessionCount,
SUM(rs.durationSeconds) as totalDurationSeconds
COALESCE(SUM(rs.durationSeconds), 0) as totalDurationSeconds
FROM ReadingSessionEntity rs
WHERE rs.user.id = :userId
AND (:year IS NULL OR YEAR(rs.startTime) = :year)
@@ -90,8 +90,8 @@ export class FavoriteDaysChartComponent implements OnInit, OnDestroy {
if (label === 'Sessions') {
return `${label}: ${value} session${value !== 1 ? 's' : ''}`;
} else {
const hours = Math.floor(value / 3600);
const minutes = Math.floor((value % 3600) / 60);
const hours = Math.floor(value);
const minutes = Math.floor((value % 1) * 60);
return `${label}: ${hours}h ${minutes}m`;
}
}