Skip to content

Commit

Permalink
Fix: DO-3658: Fix Table non-unique index values, fix sorting by unnam…
Browse files Browse the repository at this point in the history
…ed index (#363)
  • Loading branch information
Roman-Kornev authored Aug 23, 2024
1 parent 1d2d63a commit 26fe0ca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions packages/dara-core/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
title: Changelog
---

## NEXT

- Fixed a crash in `Table` pagination where rows containing non-unique index values would cause a slicing error.
- Fixed an issue in `Table` where sorting by an unnamed index would not work.

## 1.12.6

- Fix an issue where LRU cache could result in a `KeyError`
Expand Down
10 changes: 6 additions & 4 deletions packages/dara-core/dara/core/interactivity/filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,14 +274,16 @@ def apply_filters(
order_by = order_by[1:]
ascending = False

new_data = new_data.sort_values(
by=re.sub(COLUMN_PREFIX_REGEX, '', order_by), ascending=ascending, inplace=False
)
col = re.sub(COLUMN_PREFIX_REGEX, '', order_by)
if col == 'index':
new_data = new_data.sort_index(ascending=ascending, inplace=False)
else:
new_data = new_data.sort_values(by=col, ascending=ascending, inplace=False)

# PAGINATE
start_index = pagination.offset if pagination.offset is not None else 0
stop_index = start_index + pagination.limit if pagination.limit is not None else total_count

new_data = new_data[start_index:stop_index]
new_data = new_data.iloc[start_index:stop_index]

return new_data, total_count

0 comments on commit 26fe0ca

Please sign in to comment.