Skip to content

Conversation

@gyordong
Copy link
Contributor

@gyordong gyordong commented Oct 28, 2024

Description

My partner @aduques and I changed some functions using sortBy() to use localeCompare() instead. This allowed text with accents in them to be order properly (i.e, before changes it was caa, cna, cáa, cña, now it's properly ordered as caa, cáa, cna, cña)

Fixes #1188

Type of change

  • Note merging this changes the database configuration.
  • This change requires a documentation update

Checklist

  • I have followed the OED pull request ideas
  • I have removed text in ( ) from the issue request
  • You acknowledge that every person contributing to this work has signed the OED Contributing License Agreement and each author is listed in the Description section.

Limitations

Some files, specifically uiSelectors, determineCompatibleUnits, and input, have undefined set as the locale argument for localeCompare(). The alphabetic ordering for accents worked for all languages with undefined set, but we can change it to use the selected language if deemed necessary. We left TODOs on these specific files for later developers to locate and change if it ever becomes an issue in the future.

gyordong and others added 22 commits October 14, 2024 18:41
…to localeCompare() on some files (still needs testing
…ortBy() to localeCompare() on some files (still needs testing"

This reverts commit 8d2c2d4.
…) to localeCompare(), tested by comparing the group and meter options when creating a new group
… graphic units on create a group page (might need further testing)
…he generated csv files of graphs; removed commented out old code
@huss
Copy link
Member

huss commented Oct 29, 2024

Thanks to @gyordong and @aduques for this contribution. My records do not indicate that @aduques has signed the OED CLA. That is needed to review/accept this contribution. If you think my records are off then please let me know.

@aduques
Copy link
Contributor

aduques commented Oct 29, 2024

Thanks to @gyordong and @aduques for this contribution. My records do not indicate that @aduques has signed the OED CLA. That is needed to review/accept this contribution. If you think my records are off then please let me know.

I have finished signing the OED CLA.

Copy link
Member

@huss huss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks to @gyordong & @aduques for another contribution. Overall, this works as desired. I made a few comments. Some are straightforward. Some came from my thinking more deeply about the sorting based on the changes you made. I welcome your thoughts on my comments and deciding how to address them.

…elector() called in top level component rather than separately in functions
…elector() called in top level component rather than separately in functions
… selectMeterGroupSelectData() and selectUnitSelectData() to include selectSelectedLanguage in appSelector
…erMenuOptionsForGroup(), updated useEffects for CreateGroupModalComponent() and EditGroupModalComponent() to include locale as arguments.
… updated selectPossibleGraphicUnits() in adminSelectors to include language as an argument, cleaned up TODO and typecasted locale into String for determinecompatibleunits for getMeterMenuOptionsForGroup
Copy link
Member

@huss huss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks to @gyordong for quickly and carefully addressing all the previous comments. All the changes look good and testing found no issues. I did carefully search for all uses of .sort and found a few that do not seem language aware but maybe should be. They are:

  • src/client/app/components/groups/EditGroupModalComponent.tsx: has two .sort that are not locale aware
  • src/client/app/components/conversion/ConversionsDetailComponent.tsx: has one .sort that are not locale aware
  • src/client/app/components/admin/users/UsersDetailComponent.tsx: has one .sort that are not locale aware
  • src/client/app/components/MultiCompareChartComponent.tsx: has a manual ordered sort of identifier that does not seem locale aware.

Do you think they should be? I'm hoping all but the last one are fairly straightforward if a change is needed. I know this potentially means more changes but it might get the entire code base in a great place. I appreciate your consideration and I'm happy to help as you wish.

@gyordong
Copy link
Contributor Author

I've implemented all of your requests except for MultiCompareChartComponent, as only Alphabetical uses a string comparison and the other two sortingorders, ascending and descending, which sorts it off of the change of the unit and are numerical.

@huss
Copy link
Member

huss commented Oct 31, 2024

requests except for MultiCompareChartComponent, as only Alphabetical uses a string comparison and the other two sortingorders, ascending and descending, which sorts it

Yes, that was what I was thinking. Only the string one should be modified (as you did).

Copy link
Member

@huss huss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I again thank @gyordong for quick, quality changes. Everything looks great. I appreciate your willingness to do extra work to make this be a comprehensive solution. Congratulations to you and @aduques on another accepted contribution to OED.

@huss huss merged commit 0633a96 into OpenEnergyDashboard:development Oct 31, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

how items are sorted

3 participants