feat: add normalize_sort_by hashable cache-key helper (#72)

Add normalize_sort_by function to convert Dash DataTable's sort_by list
(unhashable) into a tuple representation (hashable) for use in cache keys.
Includes TDD-driven tests for empty inputs, hashability, and order preservation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Colin Maudry
2026-04-19 22:36:55 +02:00
parent ff425108b0
commit 18d07b5398
2 changed files with 40 additions and 0 deletions
+6
View File
@@ -146,6 +146,12 @@ def dates_to_strings(lff: pl.LazyFrame, column: str) -> pl.LazyFrame:
return lff
def normalize_sort_by(sort_by) -> tuple:
if not sort_by:
return ()
return tuple((entry["column_id"], entry["direction"]) for entry in sort_by)
def format_number(number) -> str:
number = "{:,}".format(number).replace(",", " ")
return number