Add configurable sync_lookback_days for Garmin Connect
Users can now set how many days back the first sync fetches. -1 syncs all history back to 2010; any positive value sets a rolling window. Values over 365 show a rate-limit warning in the UI. The default remains 30 days. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -115,7 +115,7 @@ export default function ProfilePage() {
|
||||
queryKey: ['garmin-config'],
|
||||
queryFn: () => api.get('/garmin-sync/config').then(r => r.data),
|
||||
})
|
||||
const [gcForm, setGcForm] = useState({ email: '', password: '', sync_enabled: true, sync_activities: true, sync_wellness: true })
|
||||
const [gcForm, setGcForm] = useState({ email: '', password: '', sync_enabled: true, sync_activities: true, sync_wellness: true, sync_lookback_days: 30 })
|
||||
const [gcSaved, setGcSaved] = useState(false)
|
||||
const [gcError, setGcError] = useState('')
|
||||
const [gcSyncing, setGcSyncing] = useState(false)
|
||||
@@ -127,6 +127,7 @@ export default function ProfilePage() {
|
||||
sync_enabled: garminConfig.sync_enabled,
|
||||
sync_activities: garminConfig.sync_activities,
|
||||
sync_wellness: garminConfig.sync_wellness,
|
||||
sync_lookback_days: garminConfig.sync_lookback_days ?? 30,
|
||||
}))
|
||||
}
|
||||
}, [garminConfig])
|
||||
@@ -145,7 +146,7 @@ export default function ProfilePage() {
|
||||
mutationFn: () => api.delete('/garmin-sync/config'),
|
||||
onSuccess: () => {
|
||||
refetchGarmin()
|
||||
setGcForm({ email: '', password: '', sync_enabled: true, sync_activities: true, sync_wellness: true })
|
||||
setGcForm({ email: '', password: '', sync_enabled: true, sync_activities: true, sync_wellness: true, sync_lookback_days: 30 })
|
||||
},
|
||||
})
|
||||
const triggerGarminSync = async () => {
|
||||
@@ -345,6 +346,14 @@ export default function ProfilePage() {
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<Field label="Sync lookback days" hint="-1 syncs all available history (back to 2010). Leave at 30 for incremental syncs.">
|
||||
<Input type="number" value={gcForm.sync_lookback_days} min={-1}
|
||||
onChange={e => setGcForm(f => ({ ...f, sync_lookback_days: parseInt(e.target.value, 10) || 30 }))} />
|
||||
{gcForm.sync_lookback_days > 365 && gcForm.sync_lookback_days !== -1 && (
|
||||
<p className="text-yellow-400 text-xs mt-1">Warning: syncing more than 365 days at once may take a long time and could trigger Garmin rate limits.</p>
|
||||
)}
|
||||
</Field>
|
||||
</div>
|
||||
|
||||
{gcError && <p className="text-red-400 text-xs">{gcError}</p>}
|
||||
|
||||
Reference in New Issue
Block a user