File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change 66 * Copyright Oxide Computer Company
77 */
88
9+ import { differenceInMinutes } from 'date-fns'
910import { useMemo } from 'react'
1011import * as R from 'remeda'
1112
@@ -46,7 +47,29 @@ import { percentage, round } from '~/util/math'
4647
4748export const handle = makeCrumb ( 'System Update' )
4849
49- const statusQuery = apiq ( 'systemUpdateStatus' , { } )
50+ const SEC = 1000 // ms, obviously
51+ const POLL_FAST = 20 * SEC
52+ const POLL_SLOW = 120 * SEC
53+
54+ const statusQuery = apiq (
55+ 'systemUpdateStatus' ,
56+ { } ,
57+ {
58+ refetchInterval ( { state : { data : status } } ) {
59+ if ( ! status ) return false // should be impossible due to prefetch
60+
61+ const now = new Date ( )
62+ const minSinceTargetSet = status . targetRelease
63+ ? differenceInMinutes ( now , status . targetRelease . timeRequested )
64+ : null
65+ const minSinceLastStepPlanned = differenceInMinutes ( now , status . timeLastStepPlanned )
66+ return minSinceLastStepPlanned < 30 ||
67+ ( minSinceTargetSet !== null && minSinceTargetSet < 30 )
68+ ? POLL_FAST
69+ : POLL_SLOW
70+ } ,
71+ }
72+ )
5073const reposQuery = apiq ( 'systemUpdateRepositoryList' , { query : { limit : ALL_ISH } } )
5174
5275const refreshData = ( ) =>
You can’t perform that action at this time.
0 commit comments