Loading
refactor: Make sort handling mode-aware and consistent
What does this MR do and why?
Resolves #125 (closed).
The current sort implementation has an inconsistency between standard and analytics modes:
- In standard mode,
graphql_sort_valuereturns both the sort field identifier and direction combined (e.g.CREATED_AT_DESC), and codegen passes it through directly as thesort:parameter. - In analytics mode,
graphql_sort_valuereturns only the identifier (e.g.acceptanceRate), and codegen readssort.orderseparately to append direction manually.
This MR refactors sort handling so that:
graphql_sort_valueconsistently returns only the sort identifier across all modes and sources.- Codegen is responsible for appending direction in all cases, using the new
SortOrder::graphql_direction()helper. types/sort.rsis the single source of truth for direction formatting (ASC/DESC).
Changes
src/types/sort.rs: AddedSortOrder::graphql_direction()method returning"ASC"or"DESC". RemovedSort::format_graphql_value()which mixed identifier and direction concerns and is no longer needed.src/analyzer/sources/merge_requests.rs,work_items.rs,projects.rs: Updatedgraphql_sort_valueto return only the identifier (e.g."CREATED_AT"instead of"CREATED_AT_DESC").src/codegen/graphql/standard.rs: Updated to append direction viasort.order.graphql_direction()when building thesort:filter.src/codegen/graphql/analytics.rs: Updated to usesort.order.graphql_direction()instead of a manualSortOrder::Descendingcomparison, removing theSortOrderimport.
How to set up and validate locally
-
Build and run tests:
cargo test -
Verify sort tests still pass (these cover all standard mode sort combinations):
cargo test --test sort_tests -
Verify code suggestion analytics sort still works:
cargo test --test code_suggestion_tests test_code_suggestion_with_sort