Search in sources :

Example 1 with StatisticsField

use of com.epam.ta.reportportal.entity.statistics.StatisticsField in project commons-dao by reportportal.

the class TestItemRepositoryCustomImpl method accumulateStatisticsByFilter.

@Override
public Set<Statistics> accumulateStatisticsByFilter(Queryable filter) {
    return dsl.fetch(DSL.with(FILTERED_QUERY).as(QueryBuilder.newBuilder(filter, QueryUtils.collectJoinFields(filter)).build()).select(DSL.sum(STATISTICS.S_COUNTER).as(ACCUMULATED_STATISTICS), STATISTICS_FIELD.NAME).from(STATISTICS).join(DSL.table(name(FILTERED_QUERY))).on(STATISTICS.ITEM_ID.eq(field(name(FILTERED_QUERY, FILTERED_ID), Long.class))).join(STATISTICS_FIELD).on(STATISTICS.STATISTICS_FIELD_ID.eq(STATISTICS_FIELD.SF_ID)).groupBy(STATISTICS_FIELD.NAME).getQuery()).intoSet(r -> {
        Statistics statistics = new Statistics();
        StatisticsField statisticsField = new StatisticsField();
        statisticsField.setName(r.get(STATISTICS_FIELD.NAME));
        statistics.setStatisticsField(statisticsField);
        statistics.setCounter(ofNullable(r.get(ACCUMULATED_STATISTICS, Integer.class)).orElse(0));
        return statistics;
    });
}
Also used : StatisticsField(com.epam.ta.reportportal.entity.statistics.StatisticsField) Statistics(com.epam.ta.reportportal.entity.statistics.Statistics)

Aggregations

Statistics (com.epam.ta.reportportal.entity.statistics.Statistics)1 StatisticsField (com.epam.ta.reportportal.entity.statistics.StatisticsField)1