-
Notifications
You must be signed in to change notification settings - Fork 12
fix: resolve search ranking showing N/A on admin page #256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
4dedb0f
576e3d5
c2a079b
f54b797
cf1086c
7e31cd5
b86c9cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -9,9 +9,19 @@ import { CustomPagination } from "@/components/common/CustomPagination"; | |||||||||||||||||||||||
| import withAdmin from "@/components/common/HOC/authAdmin"; | ||||||||||||||||||||||||
| import { formatDownloadCount } from "@/components/nodes/NodeDetails"; | ||||||||||||||||||||||||
| import SearchRankingEditModal from "@/components/nodes/SearchRankingEditModal"; | ||||||||||||||||||||||||
| import { Node, useSearchNodes } from "@/src/api/generated"; | ||||||||||||||||||||||||
| import { Node, useGetNode, useSearchNodes } from "@/src/api/generated"; | ||||||||||||||||||||||||
| import { useNextTranslation } from "@/src/hooks/i18n"; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| function NodeSearchRankingCell({ nodeId }: { nodeId: string }) { | ||||||||||||||||||||||||
| const { t } = useNextTranslation(); | ||||||||||||||||||||||||
| const { data: node, isLoading } = useGetNode(nodeId, { | ||||||||||||||||||||||||
| staleTime: 5 * 60 * 1000, | ||||||||||||||||||||||||
| refetchOnWindowFocus: false, | ||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||
| if (isLoading) return <Spinner size="xs" />; | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
| const { data: node, isLoading } = useGetNode(nodeId, { | |
| staleTime: 5 * 60 * 1000, | |
| refetchOnWindowFocus: false, | |
| }); | |
| if (isLoading) return <Spinner size="xs" />; | |
| const { data: node, isLoading, isError } = useGetNode(nodeId, { | |
| staleTime: 5 * 60 * 1000, | |
| refetchOnWindowFocus: false, | |
| }); | |
| if (isLoading) return <Spinner size="xs" />; | |
| if (isError) return <>Error</>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 7e31cd5. Added isError handling that shows an explicit "Error" state instead of silently displaying N/A.
Copilot
AI
Apr 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
node.id is optional in the generated Node type; passing node.id || "" means the query will be disabled when id is missing and the cell will silently show N/A. Prefer guarding before rendering (e.g., only render the cell when node.id is truthy) so missing IDs are handled explicitly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 7e31cd5. Now guarding node.id before rendering NodeSearchRankingCell — renders t("N/A") directly when id is missing, avoiding the empty-string query key issue.
Copilot
AI
Apr 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rendering NodeSearchRankingCell for each row introduces an N+1 pattern (up to 24 extra GET /nodes/{id} requests per page load/search/pagination). This can significantly slow the admin page and increase API load; consider adding search_ranking to /nodes/search for admin responses, or introducing a batch endpoint / query that fetches rankings for the current page in one request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Acknowledged the N+1 concern. The ideal fix is to extend /nodes/search to include search_ranking for admin responses on the backend. This approach is a workaround since the frontend can't modify the API response. Added staleTime: 5min and refetchOnWindowFocus: false (now correctly placed in query options per 7e31cd5) to mitigate repeated refetches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useGetNode's second argument isparams(querystring), not React Query options. Passing{ staleTime, refetchOnWindowFocus }here will be sent as request params and the caching options won't apply. Move these under the 3rd argument asoptions: { query: { staleTime, refetchOnWindowFocus } }(and keepparamsasundefinedunless needed).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 7e31cd5. Moved
staleTimeandrefetchOnWindowFocusto the 3rd argument underoptions.query, and passedundefinedfor params. Also addedenabled: !!nodeIdto prevent queries with empty strings.