Skip to content
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

NickAkhmetov/CAT-634 Fix selection of samples on organ page when more than 500 are present #3595

Merged
merged 2 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG-cat-634-fix-infinite-scroll-selection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Adjust ID fetching for infinite scroll table to ensure "select all" functionality works as expected.
15 changes: 4 additions & 11 deletions context/app/static/js/hooks/useSearchData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export function useAllSearchIDs(
const { elasticsearchEndpoint, groupsToken } = useAppContext();

const { searchData } = useSearchData(
{ ...query, track_total_hits: true, size: 0, ...sharedIDsQueryClauses },
{ ...query, track_total_hits: true, size: 10000, ...sharedIDsQueryClauses },
{
useDefaultQuery,
fetcher,
Expand All @@ -243,21 +243,14 @@ export function useAllSearchIDs(
);

const totalHitsCount = getTotalHitsCount(searchData);
const numberOfPagesToRequest = totalHitsCount ? Math.ceil(10000 / totalHitsCount) : undefined;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this continue to handle > 10k results?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is definitely worth testing to be safe in the long run - I can test it out with a query for all samples without any filters and confirm whether it works as expected.

The 10k results limitation is definitely worth keeping in mind in general, but I am curious - per #3593, it seems like we aren't as close to the 10k result threshold as we thought once we filter samples without descendant datasets, so maybe this could be a premature optimization?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would slightly prefer to keep the logic to handle this in place rather than have to re-visit suddenly it in the future if something changes.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have ~7k datasets with HuBMAP Read.


const getKey: SWRInfiniteKeyLoader = useCallback(() => {
if (numberOfPagesToRequest === undefined) {
if (totalHitsCount === undefined) {
return null;
}

return [
{ ...query, ...sharedIDsQueryClauses },
elasticsearchEndpoint,
groupsToken,
useDefaultQuery,
numberOfPagesToRequest,
];
}, [query, elasticsearchEndpoint, groupsToken, useDefaultQuery, numberOfPagesToRequest]);
return [{ ...query, ...sharedIDsQueryClauses, size: 10000 }, elasticsearchEndpoint, groupsToken, useDefaultQuery];
}, [totalHitsCount, query, elasticsearchEndpoint, groupsToken, useDefaultQuery]);

// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-argument
// @ts-expect-error - revisit to make these keys more type safe
Expand Down
Loading