Skip to content

Commit

Permalink
perf: gh-42 updated queries refetch config.
Browse files Browse the repository at this point in the history
  • Loading branch information
riccox committed Jun 21, 2023
1 parent 833b7f6 commit 47e1337
Show file tree
Hide file tree
Showing 20 changed files with 14 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ export const Header: FC<Props> = ({ client }) => {
async () => {
return await client.getVersion();
},
{ refetchOnMount: 'always', refetchInterval: 60000, onSuccess: (res) => setVersion(res) }
{ refetchInterval: 120000, onSuccess: (res) => setVersion(res) }
);
useQuery(
['health', currentInstance?.host],
async () => {
return (await client.health()).status === 'available';
},
{ refetchOnMount: 'always', refetchInterval: 5000, onSuccess: (res) => setHealth(res) }
{ refetchInterval: 30000, onSuccess: (res) => setHealth(res) }
);

const onClickHost = useCallback(() => {
Expand Down
2 changes: 0 additions & 2 deletions src/components/Settings/baseInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ export const BaseInfo: FC<IndexSettingComponentProps> = ({ host, client }) => {
},
{
keepPreviousData: true,
refetchOnMount: 'always',
refetchInterval: 3000,
onSuccess: () => {
// change display data when not editing
!isRawInfoEditing && resetRawInfo();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export const DisplayedAttributes: FC<IndexSettingConfigComponentProps> = ({
}) => {
const query = useQuery({
queryKey: ['getDisplayedAttributes', host, client.uid],
refetchInterval: 4500,
async queryFn(ctx) {
return await client.getDisplayedAttributes();
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import _ from 'lodash';
export const DistinctAttribute: FC<IndexSettingConfigComponentProps> = ({ client, className, host, toggleLoading }) => {
const query = useQuery({
queryKey: ['getDistinctAttribute', host, client.uid],
refetchInterval: 4500,
async queryFn(ctx) {
return await client.getDistinctAttribute();
},
Expand Down
1 change: 0 additions & 1 deletion src/components/Settings/config/detail/faceting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import _ from 'lodash';
export const Faceting: FC<IndexSettingConfigComponentProps> = ({ client, className, host, toggleLoading }) => {
const query = useQuery({
queryKey: ['getFaceting', host, client.uid],
refetchInterval: 4500,
async queryFn(ctx) {
return (await client.getFaceting()) as TFaceting;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const FilterableAttributes: FC<IndexSettingConfigComponentProps> = ({
}) => {
const query = useQuery({
queryKey: ['getFilterableAttributes', host, client.uid],
refetchInterval: 4500,
async queryFn(ctx) {
return await client.getFilterableAttributes();
},
Expand Down
1 change: 0 additions & 1 deletion src/components/Settings/config/detail/pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import _ from 'lodash';
export const Pagination: FC<IndexSettingConfigComponentProps> = ({ client, className, host, toggleLoading }) => {
const query = useQuery({
queryKey: ['getPagination', host, client.uid],
refetchInterval: 4500,
async queryFn(ctx) {
return (await client.getPagination()) as TPagination;
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/Settings/config/detail/rankingRules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import _ from 'lodash';
export const RankingRules: FC<IndexSettingConfigComponentProps> = ({ client, className, host, toggleLoading }) => {
const query = useQuery({
queryKey: ['getRankingRules', host, client.uid],
refetchInterval: 4500,

async queryFn(ctx) {
return await client.getRankingRules();
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const SearchableAttributes: FC<IndexSettingConfigComponentProps> = ({
}) => {
const query = useQuery({
queryKey: ['getSearchableAttributes', host, client.uid],
refetchInterval: 4500,

async queryFn(ctx) {
return await client.getSearchableAttributes();
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const SortableAttributes: FC<IndexSettingConfigComponentProps> = ({
}) => {
const query = useQuery({
queryKey: ['getSortableAttributes', host, client.uid],
refetchInterval: 4500,

async queryFn(ctx) {
return await client.getSortableAttributes();
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/Settings/config/detail/stopWords.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { IconAlertTriangleFilled, IconInfoCircleFilled } from '@tabler/icons-rea
export const StopWords: FC<IndexSettingConfigComponentProps> = ({ client, className, host, toggleLoading }) => {
const query = useQuery({
queryKey: ['getStopWords', host, client.uid],
refetchInterval: 4500,

async queryFn(ctx) {
return await client.getStopWords();
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/Settings/config/detail/synonyms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const Synonyms: FC<IndexSettingConfigComponentProps> = ({ client, classNa

const query = useQuery({
queryKey: ['getSynonyms', host, client.uid],
refetchInterval: 4500,

async queryFn(ctx) {
return (await client.getSynonyms()) as TSynonyms;
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/Settings/config/detail/typoTolerance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import _ from 'lodash';
export const TypoTolerance: FC<IndexSettingConfigComponentProps> = ({ client, className, host, toggleLoading }) => {
const query = useQuery({
queryKey: ['getTypoTolerance', host, client.uid],
refetchInterval: 4500,

async queryFn(ctx) {
return (await client.getTypoTolerance()) as TTypoTolerance;
},
Expand Down
2 changes: 0 additions & 2 deletions src/components/Settings/config/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ export const Editor: FC<IndexSettingConfigComponentProps> = ({ client, host, cla
},
{
keepPreviousData: true,
refetchInterval: 5000,
refetchOnMount: 'always',
onSuccess: (data) => {
// change display data when not editing
!isSettingsEditing && resetSettings(data);
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useIndexes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const useIndexes = (client: MeiliSearch, params?: IndexesQuery): [Index[]
async () => {
return (await client.getIndexes(params)).results;
},
{ refetchOnMount: 'always', refetchInterval: 10000, onSuccess: (res) => setIndexes(res) }
{ onSuccess: (res) => setIndexes(res) }
);

return [indexes, query];
Expand Down
2 changes: 0 additions & 2 deletions src/hooks/useInstanceStats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ export const useInstanceStats = (client: MeiliSearch) => {
return await client.getStats();
},
{
refetchOnMount: 'always',
refetchInterval: 10000,
onSuccess: (res) => setStats(res),
onError: (err) => {
console.warn('get meilisearch stats error', err);
Expand Down
4 changes: 0 additions & 4 deletions src/pages/index/documents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ export const Documents = () => {
{
enabled: !!currentIndex,
keepPreviousData: true,
refetchOnMount: 'always',
refetchInterval: 30000,
}
);

Expand Down Expand Up @@ -124,8 +122,6 @@ export const Documents = () => {
{
enabled: !!currentIndex,
keepPreviousData: true,
refetchOnMount: 'always',
refetchInterval: 5000,
}
);
const [isAddDocumentsByEditorModalOpen, setIsAddDocumentsByEditorModalOpen] = useState(false);
Expand Down
1 change: 0 additions & 1 deletion src/pages/key/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ function Keys() {
},
{
keepPreviousData: true,
refetchOnMount: 'always',
getNextPageParam: (lastPage) => {
const limit = lastPage.limit ?? 20;
const offset = lastPage.offset ?? 0;
Expand Down
1 change: 0 additions & 1 deletion src/pages/task/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ function Tasks() {
},
{
keepPreviousData: true,
refetchOnMount: 'always',
getNextPageParam: (lastPage, pages) => ({ from: lastPage.next }),
onError: (err) => {
console.warn('get meilisearch tasks error', err);
Expand Down
5 changes: 5 additions & 0 deletions src/providers/react-query.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ const queryClient = new QueryClient({
queries: {
suspense: true,
useErrorBoundary: true,
refetchIntervalInBackground: false,
refetchOnReconnect: 'always',
refetchOnMount: 'always',
refetchOnWindowFocus: 'always',
refetchInterval: 30000,
},
},
});
Expand Down

0 comments on commit 47e1337

Please sign in to comment.