tweak: update rolling perofrmance

This commit is contained in:
2026-06-27 14:24:08 +09:30
parent eae2e0587c
commit 2163f06de9
3 changed files with 17 additions and 6 deletions
@@ -341,13 +341,13 @@
aria-haspopup="menu" aria-haspopup="menu"
aria-expanded={menuOpen} aria-expanded={menuOpen}
aria-busy={isBusy} aria-busy={isBusy}
aria-label={status.connected ? "Google Calendar sync options" : "Connect Google Calendar"} aria-label={status.connected ? "Google Calendar sync options" : "Sync with Calendar"}
onclick={() => { onclick={() => {
if (!isBusy) toggleMenu(); if (!isBusy) toggleMenu();
}} }}
> >
<span class="bsplus-cal-trigger-icon" aria-hidden="true">&#xe9cd;</span> <span class="bsplus-cal-trigger-icon" aria-hidden="true">&#xe9cd;</span>
<span class="bsplus-cal-trigger-text">Calendar</span> <span class="bsplus-cal-trigger-text">Sync with Calendar</span>
{#if status.connected} {#if status.connected}
<span class="bsplus-cal-status-dot" aria-hidden="true"></span> <span class="bsplus-cal-status-dot" aria-hidden="true"></span>
{/if} {/if}
@@ -433,7 +433,7 @@
/> />
</label> </label>
<p class="bsplus-cal-setting-hint"> <p class="bsplus-cal-setting-hint">
Keeps a rolling {syncWeeksAhead}-week window. Each week adds the next week and removes the oldest. Syncs {syncWeeksAhead} weeks ahead on connect and manual sync. Weekly auto-sync adds each new week forward.
</p> </p>
</div> </div>
{/if} {/if}
@@ -97,6 +97,19 @@ describe("syncLessonsToGoogleCalendar", () => {
}); });
}); });
it("does not delete events during incremental sync", async () => {
const result = await syncLessonsToGoogleCalendar(
{ origin: ORIGIN, lessons: [baseLesson], mode: "incremental" },
getAccessToken,
);
expect(deleteGoogleCalendarEvent).not.toHaveBeenCalled();
expect(result).toMatchObject({
success: true,
deleted: 0,
});
});
it("reports progress while syncing", async () => { it("reports progress while syncing", async () => {
const progress: Array<{ phase: string; current: number; total: number }> = []; const progress: Array<{ phase: string; current: number; total: number }> = [];
await syncLessonsToGoogleCalendar( await syncLessonsToGoogleCalendar(
+1 -3
View File
@@ -7,7 +7,6 @@ import {
normalizeEventMapEntry, normalizeEventMapEntry,
} from "@/seqta/utils/googleCalendar/eventMapEntry"; } from "@/seqta/utils/googleCalendar/eventMapEntry";
import { import {
droppedWeekRange,
isDateInRange, isDateInRange,
syncWindowRange, syncWindowRange,
} from "@/seqta/utils/googleCalendar/syncDateRange"; } from "@/seqta/utils/googleCalendar/syncDateRange";
@@ -120,7 +119,6 @@ function entriesToPrune(
currentMapKeys: Set<string>, currentMapKeys: Set<string>,
): Array<[string, string]> { ): Array<[string, string]> {
const window = syncWindowRange(weeksAhead); const window = syncWindowRange(weeksAhead);
const dropped = droppedWeekRange(weeksAhead);
const prefix = `${origin}::`; const prefix = `${origin}::`;
const entries: Array<[string, string]> = []; const entries: Array<[string, string]> = [];
@@ -131,7 +129,7 @@ function entriesToPrune(
let shouldDelete = false; let shouldDelete = false;
if (mode === "incremental") { if (mode === "incremental") {
shouldDelete = !!entry.date && isDateInRange(entry.date, dropped); shouldDelete = false;
} else if (entry.date) { } else if (entry.date) {
shouldDelete = !isDateInRange(entry.date, window); shouldDelete = !isDateInRange(entry.date, window);
} else { } else {