From 1bcd2c69e371e9d58390265e6c33f0c338f84928 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Tue, 19 May 2026 17:00:30 +0000
Subject: [PATCH 1/3] feat(view): add fixed event time range options
Agent-Logs-Url: https://github.com/ut-code/visitor-tracker/sessions/5abfa2c6-1428-435a-977e-877c343bb1d4
Co-authored-by: na-trium-144 <100704180+na-trium-144@users.noreply.github.com>
---
view/src/lib/consts.ts | 79 +++++++++++++++++++++++++++++++
view/src/routes/+page.svelte | 26 ++++++----
view/src/routes/visits/+server.ts | 27 +++++++----
3 files changed, 114 insertions(+), 18 deletions(-)
diff --git a/view/src/lib/consts.ts b/view/src/lib/consts.ts
index 306b9f8..10d5729 100644
--- a/view/src/lib/consts.ts
+++ b/view/src/lib/consts.ts
@@ -1,2 +1,81 @@
export const DAY = 24 * 60 * 60 * 1000;
export const HOUR = 60 * 60 * 1000;
+
+type RelativeTimeRangeOption = {
+ key: string;
+ label: string;
+ type: 'relative';
+ duration: number;
+};
+
+type FixedTimeRangeOption = {
+ key: string;
+ label: string;
+ type: 'fixed';
+ startAt: string;
+ endAt: string;
+};
+
+export type TimeRangeOption = RelativeTimeRangeOption | FixedTimeRangeOption;
+
+export const DEFAULT_TIME_RANGE_KEY = '12h';
+
+export const TIME_RANGE_OPTIONS: TimeRangeOption[] = [
+ { key: '3h', label: '3 hours', type: 'relative', duration: 3 * HOUR },
+ { key: '6h', label: '6 hours', type: 'relative', duration: 6 * HOUR },
+ { key: '12h', label: '12 hours', type: 'relative', duration: 12 * HOUR },
+ { key: '1d', label: '1 day', type: 'relative', duration: 1 * DAY },
+ { key: '3d', label: '3 days', type: 'relative', duration: 3 * DAY },
+ { key: '6d', label: '6 days', type: 'relative', duration: 6 * DAY },
+ {
+ key: 'kf75',
+ label: 'kf75',
+ type: 'fixed',
+ startAt: '2024-11-22T00:00:00+09:00',
+ endAt: '2024-11-25T00:00:00+09:00'
+ },
+ {
+ key: 'kf76',
+ label: 'kf76',
+ type: 'fixed',
+ startAt: '2025-11-22T00:00:00+09:00',
+ endAt: '2025-11-25T00:00:00+09:00'
+ },
+ {
+ key: 'mf98',
+ label: 'mf98',
+ type: 'fixed',
+ startAt: '2025-05-24T00:00:00+09:00',
+ endAt: '2025-05-26T00:00:00+09:00'
+ },
+ {
+ key: 'mf99',
+ label: 'mf99',
+ type: 'fixed',
+ startAt: '2026-05-16T00:00:00+09:00',
+ endAt: '2026-05-18T00:00:00+09:00'
+ }
+];
+
+export function resolveTimeRangeByKey(key: string, now: Date): {
+ start: Date;
+ end: Date;
+ duration: number;
+} | null {
+ const option = TIME_RANGE_OPTIONS.find((item) => item.key === key);
+ if (!option) return null;
+ if (option.type === 'relative') {
+ return {
+ start: new Date(now.getTime() - option.duration),
+ end: now,
+ duration: option.duration
+ };
+ }
+ const start = new Date(option.startAt);
+ const end = new Date(option.endAt);
+ return {
+ start,
+ end,
+ duration: end.getTime() - start.getTime()
+ };
+}
diff --git a/view/src/routes/+page.svelte b/view/src/routes/+page.svelte
index 8fcb93e..d3a4db3 100644
--- a/view/src/routes/+page.svelte
+++ b/view/src/routes/+page.svelte
@@ -1,5 +1,10 @@
-