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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user