Skip to content

Commit

Permalink
[ID-741]Fix Case-Insensitive Sorting (#742)
Browse files Browse the repository at this point in the history
* add the Changelog.md

* fix sorting

* sort

* Revert "sort"

This reverts commit 4487c45.

* fix sort

* in progress

* fix

* remove empty rows

---------

Co-authored-by: Stefan Vitanov <[email protected]>
  • Loading branch information
stefanvit and Stefan Vitanov authored Dec 18, 2024
1 parent 01e7e72 commit 9ecdfde
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
### Fixed
- Fix Case-Insensitive Sorting [#741](https://github.com/rokwire/core-building-block/issues/741)

## [1.45.1] - 2024-13-10
### Fixed
- GET services/accounts returns unsorted response [#733](https://github.com/rokwire/core-building-block/issues/733)
Expand Down
9 changes: 8 additions & 1 deletion driven/storage/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -1541,7 +1541,14 @@ func (sa *Adapter) FindPublicAccounts(context TransactionContext, appID string,
}

pipeline = append(pipeline, bson.M{"$match": bson.M{"org_apps_memberships.app_org_id": appOrg.ID, "privacy.public": true}})
pipeline = append(pipeline, bson.M{"$sort": bson.D{{Key: "profile.last_name", Value: 1}, {Key: "profile.first_name", Value: 1}}})
pipeline = append(pipeline, bson.M{"$addFields": bson.M{
"normalized_last_name": bson.M{"$toLower": "$profile.last_name"},
"normalized_first_name": bson.M{"$toLower": "$profile.first_name"},
}})
pipeline = append(pipeline, bson.M{"$sort": bson.D{
{Key: "normalized_last_name", Value: 1},
{Key: "normalized_first_name", Value: 1},
}})

if offset != nil && *offset > 0 {
pipeline = append(pipeline, bson.M{"$skip": *offset})
Expand Down

0 comments on commit 9ecdfde

Please sign in to comment.