class CorruptionRiskDashboardIndicatorsStatsController extends GenericOCDSController {

    @ApiOperation(value = "Counts the indicators that are flagged, across all releases. If one "
            + "indicator has multiple types is only counted once, so this is different from flaggedStats and "
            + "cannot be reproduced by just summing up all types in flaggedStats!")
    @RequestMapping(value = "/api/totalFlags", method = {RequestMethod.POST, RequestMethod.GET},
            produces = "application/json")
    public List<Document> totalFlags(final YearFilterPagingRequest filter) {

        Aggregation agg = newAggregation(
                match(getYearDefaultFilterCriteria(filter,
                                MongoConstants.FieldNames.TENDER_PERIOD_START_DATE)),
                project().and(FLAGS_TOTAL_FLAGGED).as("totalFlagged"),
                group().sum("totalFlagged").as(Keys.FLAGGED_COUNT),
                project(Keys.FLAGGED_COUNT).andExclude(Fields.UNDERSCORE_ID)
        );

        return releaseAgg(agg);
    }

}