Skip to content

Commit

Permalink
Ordered the returned projects by block index and returned top to bottom
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidGershony committed Aug 16, 2024
1 parent 86e523f commit c5a5421
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Blockcore.Indexer.Angor/Storage/Mongo/AngorMongoData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Blockcore.Indexer.Core.Crypto;
using Blockcore.Indexer.Core.Operations.Types;
using Blockcore.Indexer.Core.Settings;
using Blockcore.Indexer.Core.Storage;
using Blockcore.Indexer.Core.Storage.Mongo;
using Blockcore.Indexer.Core.Storage.Mongo.Types;
using Blockcore.Indexer.Core.Storage.Types;
Expand Down Expand Up @@ -227,6 +226,7 @@ public async Task<QueryResult<ProjectIndexerData>> GetProjectsAsync(int? offset,
int itemsToSkip = offset ?? ((int)total < limit ? 0 : (int)total - limit);

var projects = mongoDb.ProjectTable.AsQueryable()
.OrderBy(x => x.BlockIndex)
.Skip(itemsToSkip)
.Take(limit)
.ToList();
Expand All @@ -240,7 +240,7 @@ public async Task<QueryResult<ProjectIndexerData>> GetProjectsAsync(int? offset,
ProjectIdentifier = _.AngorKey,
TrxId = _.TransactionId,
CreatedOnBlock = _.BlockIndex
}),
}).OrderByDescending(x => x.CreatedOnBlock),
Offset = itemsToSkip,
Limit = limit,
Total = total
Expand All @@ -254,6 +254,7 @@ public async Task<QueryResult<ProjectInvestment>> GetProjectInvestmentsAsync(str
int itemsToSkip = offset ?? ((int)total < limit ? 0 : (int)total - limit);

var investments = mongoDb.InvestmentTable.AsQueryable()
.OrderBy(x => x.BlockIndex)
.Where(_ => _.AngorKey == projectId)
.Skip(itemsToSkip)
.Take(limit)
Expand Down

0 comments on commit c5a5421

Please sign in to comment.