Skip to content

Commit

Permalink
perf: optimize code
Browse files Browse the repository at this point in the history
  • Loading branch information
AElfBourneShi committed Oct 18, 2024
1 parent a3a8b6f commit f2c063d
Showing 1 changed file with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -619,11 +619,11 @@ public async Task GetList_Terms_Test()

var queryable = await _elasticsearchRepository.GetQueryableAsync();

// var predicates = inputs
// .Select(s => (Expression<Func<BlockIndex, bool>>)(info => info.BlockHash == s))
// .Aggregate((prev, next) => prev.Or(next));
// var filterList_predicate = queryable.Where(predicates).ToList();
// filterList_predicate.Count.ShouldBe(3);
var predicates = inputs
.Select(s => (Expression<Func<BlockIndex, bool>>)(info => info.BlockHash == s))
.Aggregate((prev, next) => prev.Or(next));
var filterList_predicate = queryable.Where(predicates).ToList();
filterList_predicate.Count.ShouldBe(3);

var filterList = queryable.Where(item => inputs.Contains(item.BlockHash)).ToList();
filterList.Count.ShouldBe(3);
Expand Down Expand Up @@ -659,12 +659,12 @@ public async Task GetNestedList_Terms_Test()
101,
103
};
// var queryable_predicate = await _transactionIndexRepository.GetQueryableAsync();
// var predicates = inputs
// .Select(s => (Expression<Func<TransactionIndex, bool>>)(info => info.LogEvents.Any(x => x.BlockHeight == s)))
// .Aggregate((prev, next) => prev.Or(next));
// var filterList_predicate = queryable_predicate.Where(predicates).ToList();
// filterList_predicate.Count.ShouldBe(2);
var queryable_predicate = await _transactionIndexRepository.GetQueryableAsync();
var predicates = inputs
.Select(s => (Expression<Func<TransactionIndex, bool>>)(info => info.LogEvents.Any(x => x.BlockHeight == s)))
.Aggregate((prev, next) => prev.Or(next));
var filterList_predicate = queryable_predicate.Where(predicates).ToList();
filterList_predicate.Count.ShouldBe(2);

Expression<Func<TransactionIndex, bool>> mustQuery = item =>
item.LogEvents.Any(x => inputs.Contains(x.BlockHeight));
Expand Down

0 comments on commit f2c063d

Please sign in to comment.