class TopTenController extends GenericOCDSController {

    @ApiOperation(value = "Returns the top ten largest active awards."
            + " The amount is taken from the award.value field. The returned data will contain"
            + "the following fields: "
            + "awards.date, awards.suppliers.name, "
            + "awards.value.amount, awards.suppliers.name, planning.budget (if any)")
    @RequestMapping(value = "/api/topTenLargestAwards", method = {RequestMethod.POST,
            RequestMethod.GET},
            produces = "application/json")
    public List<Document> topTenLargestAwards(@ModelAttribute @Valid final YearFilterPagingRequest filter) {

        BasicDBObject project = new BasicDBObject();
        project.put(Fields.UNDERSCORE_ID, 0);
        project.put(MongoConstants.FieldNames.AWARDS_DATE, 1);
        project.put("awards.suppliers.name", 1);
        project.put(MongoConstants.FieldNames.AWARDS_VALUE_AMOUNT, 1);
        project.put("planning.budget", 1);

        Aggregation agg = newAggregation(
                match(where(MongoConstants.FieldNames.AWARDS_VALUE_AMOUNT).exists(true)
                        .and(MongoConstants.FieldNames.AWARDS_STATUS)
                        .is(Award.Status.active.toString())
                        .andOperator(getDefaultFilterCriteria(filter))),
                unwind("awards"),
                match(getYearFilterCriteria(filter.awardFiltering(), MongoConstants.FieldNames.AWARDS_DATE)),
                new CustomOperation(new Document("$project", project)),
                sort(Direction.DESC, MongoConstants.FieldNames.AWARDS_VALUE_AMOUNT), limit(10)
        );

        return releaseAgg(agg);
    }

}