Skip to content

Commit

Permalink
fix sort
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Vitanov committed Dec 17, 2024
1 parent 753d836 commit 67d42ca
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion driven/storage/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -1559,8 +1559,15 @@ 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 67d42ca

Please sign in to comment.