Files
immich-folio/app/admin/components/analyticsDays.ts
Ralksta ad8b09700b release: v0.19.0
Release v0.19.0. See the `## [0.19.0] — 2026-09-29` section of
[CHANGELOG.md](https://github.com/ralksta/immich-folio/blob/dev/CHANGELOG.md)
for the full list.

Highlights: client proofing links (#683), custom content pages (#738),
asset picker search (#740), concurrent-edit detection (#742), env-locked
settings (#739), an accessibility baseline (#741), three security fixes
with advisories (#737, #755, #759), and a pre-release quality pass
(#780–#797).

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: ralksta <ralksta@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: Ralf <rohlenbo79@gmail.com>
Co-authored-by: Paul Thies <110185070+ImScheinox@users.noreply.github.com>
Co-authored-by: lancetm714 <108419425+lancetm714@users.noreply.github.com>
Co-authored-by: Lance Martin <lancetaylor95@gmail.com>
2026-09-29 22:50:30 +02:00

25 lines
986 B
TypeScript

/**
* The days the analytics chart shows: the last `count` calendar days up to
* `today`, each one present, with 0 for a day nobody visited.
*
* The chart used to take the last 14 *recorded* days, so a quiet week simply
* vanished and "Last 14 Days" could span a month (QA A-16).
*
* Keys are UTC dates (`YYYY-MM-DD`), the way /api/analytics/track writes them,
* so `today` is read in UTC too — a local date would be a day off either side
* of midnight.
*/
export function lastDays(
days: Record<string, { pageviews?: number } | undefined>,
count: number,
today: Date,
): Array<{ date: string; pageviews: number }> {
const end = Date.UTC(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
const out: Array<{ date: string; pageviews: number }> = [];
for (let i = count - 1; i >= 0; i--) {
const date = new Date(end - i * 86_400_000).toISOString().slice(0, 10);
out.push({ date, pageviews: days[date]?.pageviews ?? 0 });
}
return out;
}