class IssueTrendServiceImpl implements IssueTrendService, Constants {

    @Override
    public Map<String, Object> getTrendProgress(String assetGroup,
            String ruleId, LocalDate startDate, LocalDate endDate,
            String trendCategory) throws ServiceException {

        List<Map<String, Object>> trendList;
        try{
        trendList  = repository.getTrendProgress(
                assetGroup, ruleId, startDate, endDate, trendCategory);
        }catch(DataException e){
            throw new ServiceException(e);
        }
        if (!trendList.isEmpty()) {

            // Sort the list by the date in ascending order
            Comparator<Map<String, Object>> comp = (m1, m2) -> LocalDate.parse(
                    m1.get("date").toString(), DateTimeFormatter.ISO_DATE)
                    .compareTo(
                            LocalDate.parse(m2.get("date").toString(),
                                    DateTimeFormatter.ISO_DATE));
            Collections.sort(trendList, comp);
            LocalDate trendStartDate = LocalDate.parse(trendList.get(0)
                    .get("date").toString());

            // Elastic Search might not have data for some dates. But we want to
            // send consistent data to the consumers of this service, so we will
            // populate previous where data is unavailable
            fillNoDataDatesWithPrevious(trendList, trendStartDate, endDate);

            useRealTimeDataForLatestDate(trendList, assetGroup, trendCategory,
                    ruleId, null);

            // ADD compliance_percent if not available . This is done
            // temporarily.Will update with compliance_percent at source

            appendWithCompliancePercent(trendList);

            return segregateTrendProgressByWeek(assetGroup, trendList,
                    trendStartDate, endDate);
        } else {
            return new HashMap<>();
        }
    }

}