use of com.epam.ta.reportportal.database.entity.history.status.MostFailedHistory in project commons-dao by reportportal.
the class TestItemRepositoryCustomImpl method getMostFailedItemHistory.
@Override
public List<MostFailedHistory> getMostFailedItemHistory(List<String> launchIds, String criteria, int limit) {
/*
db.testItem.aggregate([
{ "$match" : { "launchRef" : { "$in" : [""]}}},
{ "$match" : { "has_childs" : false}} ,
{ "$sort" : { "start_time" : 1}},
{ "$group" : {
"_id" : "$uniqueId" ,
"total" : { "$sum" : 1 },
"name" : {"$first" : "$name"},
"statusHistory" : { "$push" : {
"time" : "$start_time",
"criteriaAmount" : "$statistics.executionCounter.failed"
}
},
"failed" : { "$sum" : "$statistics.executionCounter.failed"},
}},
{ "$match" : { "failed" : {"$gt" : 1}}},
{ "$sort" : { "failed" : -1, "total" : 1}},
{ "$limit" : 20 }
])
*/
final int MINIMUM_FOR_FAILED = 0;
Sort orders = new Sort(new Sort.Order(DESC, FAILED), new Sort.Order(ASC, TOTAL));
Aggregation aggregation = newAggregation(match(where(LAUNCH_REFERENCE).in(launchIds).and(HAS_CHILD).is(false)), sort(Sort.Direction.ASC, START_TIME), mostFailedGroup(criteria), match(where(FAILED).gt(MINIMUM_FOR_FAILED)), sort(orders), limit(limit));
return mongoTemplate.aggregate(aggregation, mongoTemplate.getCollectionName(TestItem.class), MostFailedHistory.class).getMappedResults();
}
Aggregations