feat(integrations): say where an imported Google Health history ends

The two status routes publish backfillEnded: each data type whose
backfill stopped short of the start of its history, with the instant it
reaches back to and whether the horizon or a walk that stopped moving
ended it. The integration card lists them in place of an import that
would otherwise read as still loading, in all seven locales.

Refs #1220
This commit is contained in:
Marc-André Bombeck committed 2026-10-19 17:25:57 +02:00
1 parent 72c259d85c
commit f6b09f07cd
15 files changed
+213

No files matched your search

@@ -3,6 +3,7 @@ import { apiHandler, requireAuth } from "@/lib/api-handler";
import { annotate } from "@/lib/logging/context";
import { apiSuccess } from "@/lib/api-response";
import { loadOneConnectionHealth } from "@/lib/integrations/connection-health-load";
import { googleHealthBackfillEndedList } from "@/lib/google-health/sync-core";
/**
* Get Google Health connection status for the current user (v1.26.0).
@@ -37,6 +38,7 @@ export const GET = apiHandler(async () => {
lastSyncedAt: true,
tokenExpiresAt: true,
backfillCompletedAt: true,
backfillProgress: true,
needsReauth: true,
createdAt: true,
scope: true,
@@ -57,6 +59,7 @@ export const GET = apiHandler(async () => {
tokenExpired,
tokenExpiresAt: connection.tokenExpiresAt,
backfillCompleted: !!connection.backfillCompletedAt,
backfillEnded: googleHealthBackfillEndedList(connection.backfillProgress),
needsReauth: connection.needsReauth,
scope: connection.scope,
// The one server-resolved state (ok / limited / degraded /
+9
View File
@@ -52,6 +52,10 @@ import { getPolarClientCredentials } from "@/lib/polar/credentials";
import { getStravaClientCredentials } from "@/lib/strava/credentials";
import { hasActivityScope } from "@/lib/withings/client";
import { loadConnectionHealth } from "@/lib/integrations/connection-health-load";
import {
googleHealthBackfillEndedList,
type GoogleHealthBackfillEndedEntry,
} from "@/lib/google-health/sync-core";
import type { ConnectionHealth } from "@/lib/integrations/connection-health";
export const dynamic = "force-dynamic";
@@ -156,6 +160,7 @@ export const GET = apiHandler(async () => {
lastSyncedAt: true,
createdAt: true,
backfillCompletedAt: true,
backfillProgress: true,
needsReauth: true,
},
}),
@@ -384,6 +389,9 @@ export const GET = apiHandler(async () => {
backfillCompleted: googleHealthConn
? !!googleHealthConn.backfillCompletedAt
: null,
backfillEnded: googleHealthConn
? googleHealthBackfillEndedList(googleHealthConn.backfillProgress)
: [],
// v1.27.0 — `needsReauth` is the 7-day Testing-mode refresh expiry (or a
// user-revoked grant) surfaced from the connection row; the card reads it
// to raise a distinct "Reconnect" CTA separate from parked/disconnected.
@@ -555,6 +563,7 @@ interface GoogleHealthExtras {
tokenExpiresAt: string | null;
tokenExpired: boolean | null;
backfillCompleted: boolean | null;
backfillEnded: GoogleHealthBackfillEndedEntry[];
needsReauth: boolean;
}