Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: add index to collections #109

Merged
merged 3 commits into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/api/src/dataFeeds.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
{
"feedFullName": "conflux-testnet_cfx-usdt_6",
"abi": "./src/abi/PriceFeed.json",
"address": "0x81cc73426944cC15BE22a3d7c812282E66F2c689",
"address": "0x8D7933112524bE9c143252456ac85F2a89d73f9D",
"network": "conflux-testnet",
"name": "cfx/usdt",
"label": "",
Expand Down Expand Up @@ -128,7 +128,7 @@
{
"feedFullName": "conflux-mainnet_cfx-usdt_6",
"abi": "./src/abi/PriceFeed.json",
"address": "0x86e9A67C92455afa725CC01b2036e47cd4dd9929",
"address": "0x82E6b8E6e98132a39ec96398e68Ee7bfBa0245C2",
"network": "conflux-mainnet",
"name": "cfx/usdt",
"label": "",
Expand Down Expand Up @@ -366,7 +366,7 @@
{
"feedFullName": "boba-mainnet_boba-usdt_6",
"abi": "./src/abi/PriceFeed.json",
"address": "0x52Bf8Bf503c69A055e3f86BD7D7F6dCb6c1f1E13",
"address": "0x7BC25b36DfeB5102ACAE8f4E7600Dd963D2Eb95C",
"network": "boba-mainnet",
"name": "boba/usdt",
"label": "",
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/repository/Feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class FeedRepository {
constructor (db: Db, dataFeeds: Array<FeedInfo>) {
this.collection = db.collection('feed')
this.dataFeedsFullNames = dataFeeds.map(dataFeed => dataFeed.feedFullName)
this.collection.createIndex({ feedFullName: 1 })
}

async getAll (): Promise<Array<FeedDbObjectNormalized>> {
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/repository/ResultRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class ResultRequestRepository {

constructor (db: Db, _dataFeeds: Array<FeedInfo>) {
this.collection = db.collection('result_request')
this.collection.createIndex({ feedFullName: 1 })
Copy link
Member

Choose a reason for hiding this comment

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

In ResultRequest we are looking also for timestamp: { $gt: timestamp.toString() } so the index should include it:

Suggested change
this.collection.createIndex({ feedFullName: 1 })
this.collection.createIndex({ feedFullName: 1, timestamp: -1 })

}

async getFeedRequests (
Expand Down