(key, v)
| 16000 | dashboardStatsCache = { key: null, timestamp: 0, data: null }; |
| 16001 | } |
| 16002 | |
| 16003 | async function fetchDashboardStatsForSelection(options = {}) { |
| 16004 | const { forceRefresh = false } = options; |
| 16005 | const { network } = getSelectedDashboardNetworkKey(); |
| 16006 | const cacheKey = network ? `network:${network}` : 'network:global'; |
| 16007 | const now = Date.now(); |
| 16008 | |
| 16009 | const cached = dashboardStatsCache; |
| 16010 | if (!forceRefresh && cached.key === cacheKey && (now - cached.timestamp) < DASHBOARD_STATS_CACHE_TTL && cached.data) { |
| 16011 | return cached.data; |
| 16012 | } |
| 16013 | |
| 16014 | if (!forceRefresh && dashboardStatsRequestState && dashboardStatsRequestState.key === cacheKey) { |
| 16015 | return dashboardStatsRequestState.promise; |
| 16016 | } |
| 16017 | |
| 16018 | const query = network ? `/api/dashboard/stats?network=${encodeURIComponent(network)}` : '/api/dashboard/stats'; |
| 16019 | const requestPromise = (async () => { |
| 16020 | try { |
| 16021 | const payload = await fetchAPI(query); |
| 16022 | dashboardStatsCache = { key: cacheKey, timestamp: Date.now(), data: payload }; |
| 16023 | return payload; |
| 16024 | } finally { |
no test coverage detected