vulnerablecode
vulnerablecode copied to clipboard
Improve Sorting, Pagination, and Test Coverage for Vulnerabilities and Packages Search (Fixes #1754)
This pull request introduces significant improvements to the sorting, pagination, and test coverage for the vulnerabilities and packages search pages and also fixes #1754 . The main changes include adding user-friendly sorting controls to the UI, implementing a "Reset" button for search and sorting, and adding both correctness and performance tests to ensure efficient query execution at scale.
User Interface Improvements:
- Added interactive sorting controls (ascending, descending, and reset) for columns such as "Affected by vulnerabilities", "Fixed by packages", and "Vulnerability id" in
packages.html,packages_v2.html, andvulnerabilities.html. This allows users to easily change sort order directly from the UI. [1] [2] [3] - Introduced a "⇵ Reset" button next to pagination controls that resets sorting while preserving the current search term, improving usability for users navigating large result sets. [1] [2] [3]
Testing Enhancements:
- Added new tests in
test_sort_and_queries.pyto verify correct sorting behavior for packages and vulnerabilities, and to assert that the number of database queries remains efficient (bounded) for key search and sort operations. - Introduced an opt-in performance test (
test_perf_scale.py) that bulk-creates large numbers of packages and vulnerabilities, then measures query count and execution time for searches at scale. This test is disabled by default and can be enabled via an environment variable. - Registered a custom
perfmarker inpytest.inito allow selective running of performance tests.