Skip to content

Commit

Permalink
Fixed issue with timing out queries on mongo db (#210)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidGershony authored Apr 25, 2024
1 parent 69f420e commit b4e8b49
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ public override Task OnExecute()
.CreateOne(new CreateIndexModel<Project>(Builders<Project>
.IndexKeys.Descending(x => x.BlockIndex)));

AngorMongoDb.ProjectTable.Indexes
.CreateOne(new CreateIndexModel<Project>(Builders<Project>
.IndexKeys.Ascending(x => x.AddressOnFeeOutput)));

//TODO move this to the block indexer task runner, but we'll need to move the indexes in there to a different class for each project/blockchain
AngorMongoDb.InvestmentTable.Indexes
.CreateOne(new CreateIndexModel<Investment>(Builders<Investment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ private BsonDocument[] MongoDbLookupForInvestments()
new BsonDocument
{
{ "address", "$AddressOnFeeOutput" },
{ "trx", "$TransactionId" },
{ "projectMaxBlockScanned", "$projectMaxBlockScanned" }
}
},
Expand All @@ -197,13 +196,12 @@ private BsonDocument[] MongoDbLookupForInvestments()
new BsonArray { "$Address", "$$address" }))),
new BsonDocument("$match",
new BsonDocument("$expr",
new BsonDocument("$and", new BsonArray
{
new BsonDocument("$gt",
new BsonArray { "$BlockIndex", "$$projectMaxBlockScanned" }),
new BsonDocument("$ne",
new BsonArray { "$$trx", "$Outpoint.TransactionId" })
})))
new BsonDocument("$gt",
new BsonArray { "$BlockIndex", "$$projectMaxBlockScanned" }))),
new BsonDocument("$match",
new BsonDocument("$expr",
new BsonDocument("$eq",
new BsonArray { "$Outpoint.OutputIndex", 0 }))),
}
},
{ "as", "o" }
Expand Down

0 comments on commit b4e8b49

Please sign in to comment.