Skip to content

Commit 26cdbff

Browse files
author
André Luiz Abdalla Silveira
committed
perf(issues): prevent per-second refetches
This is made by stabilizing queryKey with `roundToNearestMinutes`, and it was a crucial change as iyt might have overloaded the backend with unnecessary queries
1 parent 5c65fc0 commit 26cdbff

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

dashboard/src/api/issue.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { useQuery } from '@tanstack/react-query';
33

44
import { useSearch } from '@tanstack/react-router';
55

6+
import { roundToNearestMinutes } from 'date-fns';
7+
68
import type { IssueListingResponse } from '@/types/issueListing';
79

810
import { mapFiltersKeysToBackendCompatible } from '@/utils/utils';
@@ -16,7 +18,9 @@ import { REDUCED_TIME_SEARCH } from '@/utils/constants/general';
1618
import { RequestData } from './commonRequest';
1719

1820
const getDefaultEndTimestamp = (): number =>
19-
dateObjectToTimestampInSeconds(new Date());
21+
dateObjectToTimestampInSeconds(
22+
roundToNearestMinutes(new Date(), { nearestTo: 30 }),
23+
);
2024

2125
export const fetchIssueListing = async ({
2226
startTimestampInSeconds,

0 commit comments

Comments
 (0)