mirror of https://github.com/buster-so/buster.git
more updates
This commit is contained in:
parent
5f60420707
commit
9fbe705d06
|
@ -118,6 +118,8 @@ export const useGetMetricData = ({
|
||||||
return getMetricData({ id, version_number });
|
return getMetricData({ id, version_number });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log('data here!');
|
||||||
|
|
||||||
return useQuery({
|
return useQuery({
|
||||||
...metricsQueryKeys.metricsGetData(id, version_number),
|
...metricsQueryKeys.metricsGetData(id, version_number),
|
||||||
queryFn
|
queryFn
|
||||||
|
|
|
@ -8,12 +8,9 @@ type OpenErrorNotification = ReturnType<typeof useBusterNotifications>['openErro
|
||||||
const PREFETCH_STALE_TIME = 1000 * 10; // 10 seconds
|
const PREFETCH_STALE_TIME = 1000 * 10; // 10 seconds
|
||||||
const ERROR_RETRY_DELAY = 1 * 1000; // 1 second delay after error
|
const ERROR_RETRY_DELAY = 1 * 1000; // 1 second delay after error
|
||||||
const GC_TIME = 1000 * 60 * 60 * 24 * 3; // 24 hours - matches persistence duration
|
const GC_TIME = 1000 * 60 * 60 * 24 * 3; // 24 hours - matches persistence duration
|
||||||
const refetchOnMountRecord: Record<string, number> = PERMANENT_QUERIES.reduce<
|
|
||||||
Record<string, number>
|
// Track queries that have already mounted
|
||||||
>((acc, query) => {
|
const mountedQueries = new Set<string>();
|
||||||
acc[query] = 1;
|
|
||||||
return acc;
|
|
||||||
}, {});
|
|
||||||
|
|
||||||
function makeQueryClient(params?: {
|
function makeQueryClient(params?: {
|
||||||
openErrorNotification?: OpenErrorNotification;
|
openErrorNotification?: OpenErrorNotification;
|
||||||
|
@ -36,16 +33,22 @@ function makeQueryClient(params?: {
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
retryDelay: ERROR_RETRY_DELAY,
|
retryDelay: ERROR_RETRY_DELAY,
|
||||||
refetchOnMount: (queryClient) => {
|
refetchOnMount: (query) => {
|
||||||
if (queryClient.isActive()) {
|
console.log(query.queryHash, query.state.dataUpdatedAt);
|
||||||
if (queryClient.isActive() && !(queryClient.queryHash in refetchOnMountRecord)) {
|
if (!query.state.dataUpdatedAt) {
|
||||||
refetchOnMountRecord[queryClient.queryHash] = 0;
|
// No data has been fetched yet
|
||||||
}
|
|
||||||
refetchOnMountRecord[queryClient.queryHash]++;
|
|
||||||
return refetchOnMountRecord[queryClient.queryHash] <= 1 ? 'always' : true;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!mountedQueries.has(query.queryHash) && query.isActive()) {
|
||||||
|
// First time mounting this query
|
||||||
|
mountedQueries.add(query.queryHash);
|
||||||
|
return 'always';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Query has mounted before, use default stale time behavior
|
||||||
|
return query.state.dataUpdatedAt < Date.now() - PREFETCH_STALE_TIME;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
retry: (failureCount, error) => {
|
retry: (failureCount, error) => {
|
||||||
|
|
Loading…
Reference in New Issue