class TrendController implements Constants {

    @RequestMapping(path = "/v1/trend/issues", method = RequestMethod.POST)
    public ResponseEntity<Object> getTrendIssues(@RequestBody(required = true) CompliantTrendRequest request) {
        Map<String, Object> response = new HashMap<>();
        String assetGroup = request.getAg();
        Date input = request.getFrom();

        if (input == null) {
            Calendar cal = Calendar.getInstance();
            cal.setTimeZone(TimeZone.getTimeZone("UTC"));
            cal.add(Calendar.DATE, NEG_THIRTY);
            input = cal.getTime();
        }

        Instant instant = input.toInstant();
        ZonedDateTime zdt = instant.atZone(ZoneId.systemDefault());
        LocalDate fromDate = zdt.toLocalDate();
        LocalDate toDate = LocalDate.now();
        Map<String, String> filter = request.getFilters();

        if (Strings.isNullOrEmpty(assetGroup) || MapUtils.isEmpty(filter) || Strings.isNullOrEmpty(filter.get(DOMAIN))) {
            return ResponseUtils.buildFailureResponse(new Exception(ASSET_GROUP_DOMAIN));
        }

        String domain = filter.get(DOMAIN);

        Map<String, Object> trendIssues = new HashMap<>();
        try {
            trendIssues = trendService.getTrendIssues(assetGroup, fromDate, toDate, filter, domain);
            response.put(RESPONSE, trendIssues);
        } catch (ServiceException e) {
            LOGGER.error("Exception in getTrendIssues" , e.getMessage());
            return ResponseUtils.buildFailureResponse(e);
        }
        return ResponseUtils.buildSucessResponse(response);
    }

}