andygrove opened a new issue, #2605: URL: https://github.com/apache/datafusion-ballista/issues/2605
**Is your feature request related to a problem or challenge? Please describe what you are trying to do.** Two small duplication spots in the ballista-cli TUI domain types: - [`JobsData::sort_jobs` (tui/domain/jobs.rs#L98-L175)](https://github.com/apache/datafusion-ballista/blob/ea1126c0649b2bc08e1e233b1972b64318821c16/ballista-cli/src/tui/domain/jobs.rs#L98-L175) repeats the same `let cmp = ...; if sort_order == Descending { cmp.reverse() } else { cmp }` block in six match arms. That is why it scores cognitive complexity 42 for what is really six key extractors, and a new column means pasting the block again. - `scroll_down` / `scroll_up` and the `get_selected_*_index` accessor are copied verbatim across [ExecutorsData (executors.rs#L217-L265)](https://github.com/apache/datafusion-ballista/blob/ea1126c0649b2bc08e1e233b1972b64318821c16/ballista-cli/src/tui/domain/executors.rs#L217-L265), [JobsData (jobs.rs#L192-L240)](https://github.com/apache/datafusion-ballista/blob/ea1126c0649b2bc08e1e233b1972b64318821c16/ballista-cli/src/tui/domain/jobs.rs#L192-L240) and [MetricsData (metrics.rs#L77-L124)](https://github.com/apache/datafusion-ballista/blob/ea1126c0649b2bc08e1e233b1972b64318821c16/ballista-cli/src/tui/domain/metrics.rs#L77-L124), differing only in the backing collection. The wrap-around and empty-list handling is subtle enough that three copies can drift. **Describe the solution you'd like** - In `sort_jobs`, match on the column once to pick a comparator closure, then call `sort_by` once and apply `.reverse()` for Descending. - Add a small shared helper (e.g. `scroll_down(&mut TableState, &mut ScrollbarState, len)` / `scroll_up(...)`, or a `ScrollableTable` struct) in `tui/domain/mod.rs` and have the three types delegate to it. Move the scroll tests to the helper. **Describe alternatives you've considered** None. **Additional context** This is small and self-contained, a good first issue. Line references are pinned to commit ea1126c0649b. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
