-
-
Notifications
You must be signed in to change notification settings - Fork 18
fix: preserve table ordering from database in category responses #1616
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -103,9 +103,9 @@ export class FindTableCategoriesWithTablesUseCase | |
| tables: tablesRO, | ||
| }; | ||
| const foundTableCategoriesRO = foundTableCategories.map((category) => { | ||
| const tablesInCategory = tablesRO.filter((tableRO) => { | ||
| return category.tables.includes(tableRO.table); | ||
| }); | ||
| const tablesInCategory = category.tables | ||
| .map((tableName) => tablesRO.find((tableRO) => tableRO.table === tableName)) | ||
| .filter(Boolean); | ||
|
Comment on lines
+106
to
+108
|
||
| return { | ||
| category_id: category.category_id, | ||
| category_color: category.category_color, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes behavior when
category.tablescontains duplicates: the previousfilter(...includes...)could only include eachtablesROentry once, but the newmap(...find...)will repeat duplicates, returning the same table multiple times in the response. Consider de-duplicatingcategory.tables(while preserving order) and/or enforcing uniqueness in table-category validation so API responses stay consistent.