Skip to content

Commit

Permalink
fix(api): add collation to db index
Browse files Browse the repository at this point in the history
The collation setting was removed in a previous commit and broke how the database was sorted. In this commit, we recover the collation and include it is included in the index to avoid the delay quering not indexed data.
  • Loading branch information
gabaldon committed Mar 8, 2022
1 parent 8e29cb4 commit 05d7340
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/api/src/repository/ResultRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ export class ResultRequestRepository {

constructor (db: Db, _dataFeeds: Array<FeedInfo>) {
this.collection = db.collection('result_request')
this.collection.createIndex({ feedFullName: 1, timestamp: -1 })
this.collection.createIndex(
{ feedFullName: 1, timestamp: -1 },
{
collation: {
locale: 'en_US',
numericOrdering: true
}
}
)
}

async getFeedRequests (
Expand Down Expand Up @@ -68,6 +76,10 @@ export class ResultRequestRepository {
{
sort: {
timestamp: -1
},
collation: {
locale: 'en_US',
numericOrdering: true
}
}
)
Expand Down
1 change: 1 addition & 0 deletions packages/ui/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const mutations = {
updateSelectedNetwork(state, { network }) {
state.selectedNetwork = network
},
// TODO: refactor with cleaner approach
updateFromNavBar(state) {
state.updateFromMain = false
},
Expand Down

0 comments on commit 05d7340

Please sign in to comment.