Skip to content

Conversation

@artemmufazalov
Copy link
Member

@artemmufazalov artemmufazalov commented Dec 5, 2024

Closes #1700

  • Refactor Storage and TopShards table sort
  • Make sort in top and running queries on backend

Stand: https://nda.ya.ru/t/eyQNOFQ17AB7E2

CI Results

Test Status: βœ… PASSED

πŸ“Š Full Report

Total Passed Failed Flaky Skipped
208 208 0 0 0

😟 No changes in tests. πŸ˜•

Bundle Size: πŸ”Ί

Current: 65.86 MB | Main: 65.85 MB
Diff: +0.01 MB (0.02%)

⚠️ Bundle size increased. Please review.

ℹ️ CI Information
  • Test recordings for failed tests are available in the full report.
  • Bundle size is measured for the entire 'dist' directory.
  • πŸ“Š indicates links to detailed reports.
  • πŸ”Ί indicates increase, πŸ”½ decrease, and βœ… no change in bundle size.

"@playwright/test": "^1.42.1",
"@testing-library/jest-dom": "^6.4.6",
"@testing-library/react": "^14.2.2",
"@testing-library/react": "^16.0.1",
Copy link
Member Author

Choose a reason for hiding this comment

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

Without it there is a warning when using renderHook function

{pollingInterval: autoRefreshInterval},
);

const loading = isFetching && currentData === undefined;
Copy link
Member Author

@artemmufazalov artemmufazalov Dec 5, 2024

Choose a reason for hiding this comment

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

isLoading query param isn't false when data initially loaded, but filters change. So when we change sort order and load new data, there is no-data message instead of loader. isFetching && currentData === undefined; prevents it

@astandrik astandrik requested a review from Copilot December 6, 2024 08:42
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 14 out of 29 changed files in this pull request and generated no suggestions.

Files not reviewed (15)
  • package.json: Language not supported
  • src/containers/Tenant/Diagnostics/TopQueries/columns/i18n/en.json: Language not supported
  • src/containers/Tenant/Diagnostics/TopQueries/i18n/en.json: Language not supported
  • src/containers/Tenant/Diagnostics/TopShards/columns/i18n/en.json: Language not supported
  • src/containers/Tenant/Diagnostics/TopShards/columns/columns.tsx: Evaluated as low risk
  • src/containers/Tenant/Diagnostics/TopShards/columns/i18n/index.ts: Evaluated as low risk
  • src/containers/Storage/StorageNodes/StorageNodesTable.tsx: Evaluated as low risk
  • src/containers/Tenant/Diagnostics/TenantOverview/TenantCpu/TopQueries.tsx: Evaluated as low risk
  • src/containers/Storage/Storage.tsx: Evaluated as low risk
  • src/containers/Tenant/Diagnostics/TenantOverview/TenantCpu/TopShards.tsx: Evaluated as low risk
  • src/containers/Tenant/Diagnostics/TopShards/TopShards.tsx: Evaluated as low risk
  • src/containers/Tenant/Diagnostics/TopQueries/TopQueriesData.tsx: Evaluated as low risk
  • src/containers/Tenant/Diagnostics/TopQueries/RunningQueriesData.tsx: Evaluated as low risk
  • src/containers/Storage/StorageGroups/StorageGroupsTable.tsx: Evaluated as low risk
  • src/containers/Tenant/Diagnostics/TopQueries/columns/columns.tsx: Evaluated as low risk

...column,
sortable: isSortableTopQueriesProperty(column.name),
}));
const columns = getTopQueriesColumns();
Copy link
Collaborator

@astandrik astandrik Dec 6, 2024

Choose a reason for hiding this comment

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

Columns are recreated on every render - this could be memoized


import './Storage.scss';

export function useStorageSort<
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe move it to hooks folder? Not to expand component file with hooks. Large files with all-in-one have worse readability

const [groupsSort, handleGroupsSort] = useTableSort(groupsSortParams, (params) =>
setGroupSort(params as StorageSortParams),
);
const [nodesSort, handleNodesSort] = useStorageSort(nodesSortParams, setNodeSort);
Copy link
Collaborator

@astandrik astandrik Dec 6, 2024

Choose a reason for hiding this comment

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

Maybe istead of nesting hooks we could do more straightforward:

     function fromTableSort<T extends NodesSortParams | StorageSortParams>(
        sort: SortOrder[] | undefined,
    ): T | undefined {
        if (!sort?.[0]) {
            return undefined;
        }
    
        return {
            sortValue: sort[0].columnId,
            sortOrder: sort[0].order,
        } as T;
    }

    const [nodesSort, handleNodesSort] = useTableSort({
        initialSortColumn: nodesSortParams.sortValue,
        initialSortOrder: nodesSortParams.sortOrder,
        multiple: false,
        onSort: (sort) => setNodeSort(fromTableSort<NodesSortParams>(sort)),
    });

    const [groupsSort, handleGroupsSort] = useTableSort({
        initialSortColumn: groupsSortParams.sortValue,
        initialSortOrder: groupsSortParams.sortOrder,
        multiple: false,
        onSort: (sort) => setGroupSort(fromTableSort<StorageSortParams>(sort)),
    });

Copy link
Member Author

Choose a reason for hiding this comment

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

Current version works as before, I don't see the reason to make it beautiful, since you are deleting it anyway in #1693

@artemmufazalov artemmufazalov added this pull request to the merge queue Dec 9, 2024
Merged via the queue into main with commit bc8acee Dec 9, 2024
7 checks passed
@artemmufazalov artemmufazalov deleted the 1700-top-queries-limit branch December 9, 2024 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add limit to top queries request

3 participants