use of com.epam.ta.reportportal.entity.widget.content.ChartStatisticsContent in project service-api by reportportal.
the class ChartInvestigatedContentLoader method loadContent.
@Override
public Map<String, ?> loadContent(List<String> contentFields, Map<Filter, Sort> filterSortMapping, WidgetOptions widgetOptions, int limit) {
Filter filter = GROUP_FILTERS.apply(filterSortMapping.keySet());
Sort sort = GROUP_SORTS.apply(filterSortMapping.values());
String timeLineOption = WidgetOptionUtil.getValueByKey(TIMELINE, widgetOptions);
if (StringUtils.isNotBlank(timeLineOption)) {
Optional<Period> period = Period.findByName(timeLineOption);
if (period.isPresent()) {
Map<String, ChartStatisticsContent> statistics = groupByDate(widgetContentRepository.timelineInvestigatedStatistics(filter, sort, limit), period.get());
return MapUtils.isEmpty(statistics) ? emptyMap() : calculateInvestigatedPercentage(statistics);
}
}
List<ChartStatisticsContent> content = widgetContentRepository.investigatedStatistics(filter, sort, limit);
return CollectionUtils.isEmpty(content) ? emptyMap() : singletonMap(RESULT, content);
}
use of com.epam.ta.reportportal.entity.widget.content.ChartStatisticsContent in project service-api by reportportal.
the class LineChartContentLoader method loadContent.
@Override
public Map<String, ?> loadContent(List<String> contentFields, Map<Filter, Sort> filterSortMapping, WidgetOptions widgetOptions, int limit) {
Filter filter = GROUP_FILTERS.apply(filterSortMapping.keySet());
Sort sort = GROUP_SORTS.apply(filterSortMapping.values());
List<ChartStatisticsContent> content = widgetContentRepository.launchStatistics(filter, contentFields, sort, limit);
String timeLineOption = ofNullable(widgetOptions).map(wo -> WidgetOptionUtil.getValueByKey(TIMELINE, wo)).orElse(Strings.EMPTY);
if (StringUtils.isNotBlank(timeLineOption)) {
Optional<Period> period = Period.findByName(timeLineOption);
if (period.isPresent()) {
return CollectionUtils.isEmpty(content) ? emptyMap() : singletonMap(RESULT, groupByDate(content, period.get()));
}
}
return CollectionUtils.isEmpty(content) ? emptyMap() : singletonMap(RESULT, content);
}
use of com.epam.ta.reportportal.entity.widget.content.ChartStatisticsContent in project service-api by reportportal.
the class AbstractStatisticsContentLoader method groupStatistics.
private void groupStatistics(String groupingPattern, List<ChartStatisticsContent> statisticsContents, Map<String, ChartStatisticsContent> chart) {
Map<String, List<ChartStatisticsContent>> groupedStatistics = statisticsContents.stream().collect(Collectors.groupingBy(c -> new DateTime(c.getStartTime()).toString(groupingPattern), LinkedHashMap::new, Collectors.toList()));
groupedStatistics.forEach((key, contents) -> chart.keySet().stream().filter(k -> k.startsWith(key)).findFirst().ifPresent(k -> {
ChartStatisticsContent content = chart.get(k);
contents.add(content);
Map<String, String> values = contents.stream().map(v -> v.getValues().entrySet()).flatMap(Collection::stream).collect(Collectors.toMap(Map.Entry::getKey, entry -> ofNullable(entry.getValue()).orElse("0"), (prev, curr) -> prev = String.valueOf(Double.parseDouble(prev) + Double.parseDouble(curr))));
content.setValues(values);
chart.put(k, content);
}));
}
use of com.epam.ta.reportportal.entity.widget.content.ChartStatisticsContent in project service-api by reportportal.
the class BugTrendChartContentLoader method loadContent.
@Override
public Map<String, ?> loadContent(List<String> contentFields, Map<Filter, Sort> filterSortMapping, WidgetOptions widgetOptions, int limit) {
Filter filter = GROUP_FILTERS.apply(filterSortMapping.keySet());
Sort sort = GROUP_SORTS.apply(filterSortMapping.values());
List<ChartStatisticsContent> result = widgetContentRepository.bugTrendStatistics(filter, contentFields, sort, limit);
return result.isEmpty() ? emptyMap() : singletonMap(RESULT, result);
}
use of com.epam.ta.reportportal.entity.widget.content.ChartStatisticsContent in project service-api by reportportal.
the class LaunchExecutionAndIssueStatisticsContentLoader method loadContent.
@Override
public Map<String, ?> loadContent(List<String> contentFields, Map<Filter, Sort> filterSortMapping, WidgetOptions widgetOptions, int limit) {
Filter filter = GROUP_FILTERS.apply(filterSortMapping.keySet());
Sort sort = GROUP_SORTS.apply(filterSortMapping.values());
List<ChartStatisticsContent> content = widgetContentRepository.launchStatistics(filter, contentFields, sort, limit);
return content.isEmpty() ? emptyMap() : singletonMap(RESULT, content);
}
Aggregations