Search in sources :

Example 1 with FlakyHistory

use of com.epam.ta.reportportal.database.entity.history.status.FlakyHistory in project commons-dao by reportportal.

the class TestItemRepositoryCustomImpl method getFlakyItemStatusHistory.

@Override
public List<FlakyHistory> getFlakyItemStatusHistory(List<String> launchIds) {
    /*
			db.testItem.aggregate([
				{ "$match" : { $and: [ "launchRef" : { "$in" : [""]}, has_childs : false ]}},
				{ "$sort" : { "start_time" : 1}},
				{ "$group" : {
					"_id" : "$uniqueId" ,
					"total" : { "$sum" : 1 },
					"statusHistory" : { "$push" : {
													"status" : "$status",
													"time" : "$start_time"
													}
											},
					"statusSet" : { "$addToSet" : "$status" },
					"name" : {"$first" : "$name"},
				}},
				{ "$addFields" : { "size" : {"$size" : "$statusSet" }}},
				{ "$match" : { "size	" : {"$gt" : 1}}}
			])
	 	*/
    final int MINIMUM_FOR_FLAKY = 1;
    Aggregation aggregation = newAggregation(match(where(LAUNCH_REFERENCE).in(launchIds).and(HAS_CHILD).is(false)), sort(Sort.Direction.ASC, START_TIME), flakyItemsGroup(), addFields("size", new BasicDBObject("$size", "$statusSet")), match(where("size").gt(MINIMUM_FOR_FLAKY)));
    return mongoTemplate.aggregate(aggregation, mongoTemplate.getCollectionName(TestItem.class), FlakyHistory.class).getMappedResults();
}
Also used : Aggregation(org.springframework.data.mongodb.core.aggregation.Aggregation) BasicDBObject(com.mongodb.BasicDBObject) FlakyHistory(com.epam.ta.reportportal.database.entity.history.status.FlakyHistory)

Aggregations

FlakyHistory (com.epam.ta.reportportal.database.entity.history.status.FlakyHistory)1 BasicDBObject (com.mongodb.BasicDBObject)1 Aggregation (org.springframework.data.mongodb.core.aggregation.Aggregation)1