class CorruptionRiskDashboardIndicatorsStatsController extends GenericOCDSController {

    @ApiOperation(value = "Count total projects by year/month.")
    @RequestMapping(value = "/api/totalProjectsByYear",
            method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json")
    public List<Document> totalProjectsByYear(final YearFilterPagingRequest filter) {

        DBObject project1 = new BasicDBObject();
        addYearlyMonthlyProjection(filter, project1, ref(MongoConstants.FieldNames.TENDER_PERIOD_START_DATE));
        project1.put(Fields.UNDERSCORE_ID, 0);

        Aggregation agg = newAggregation(
                match(where(MongoConstants.FieldNames.TENDER_PERIOD_START_DATE).exists(true).
                        andOperator(getYearDefaultFilterCriteria(filter,
                                MongoConstants.FieldNames.TENDER_PERIOD_START_DATE))),
                new CustomProjectionOperation(project1),
                group(getYearlyMonthlyGroupingFields(filter)).
                        count().as(Keys.PROJECT_COUNT),
                transformYearlyGrouping(filter).andInclude(Keys.PROJECT_COUNT),
                getSortByYearMonth(filter)
        );

       return releaseAgg(agg);
    }

}