Search in sources :

Example 1 with Range

use of io.gravitee.management.rest.resource.param.Range in project gravitee-management-rest-api by gravitee-io.

the class ApplicationAnalyticsResource method executeGroupBy.

private Analytics executeGroupBy(String application, AnalyticsParam analyticsParam) {
    GroupByQuery query = new GroupByQuery();
    query.setFrom(analyticsParam.getFrom());
    query.setTo(analyticsParam.getTo());
    query.setInterval(analyticsParam.getInterval());
    query.setQuery(analyticsParam.getQuery());
    query.setField(analyticsParam.getField());
    query.setRootField("application");
    query.setRootIdentifier(application);
    if (analyticsParam.getOrder() != null) {
        GroupByQuery.Order order = new GroupByQuery.Order();
        order.setField(analyticsParam.getOrder().getField());
        order.setType(analyticsParam.getOrder().getType());
        order.setOrder(analyticsParam.getOrder().isOrder());
        query.setOrder(order);
    }
    List<Range> ranges = analyticsParam.getRanges();
    if (ranges != null) {
        Map<Double, Double> rangeMap = ranges.stream().collect(Collectors.toMap(Range::getFrom, Range::getTo));
        query.setGroups(rangeMap);
    }
    return analyticsService.execute(query);
}
Also used : GroupByQuery(io.gravitee.management.model.analytics.query.GroupByQuery) Range(io.gravitee.management.rest.resource.param.Range)

Example 2 with Range

use of io.gravitee.management.rest.resource.param.Range in project gravitee-management-rest-api by gravitee-io.

the class ApiAnalyticsResource method executeGroupBy.

private Analytics executeGroupBy(String api, AnalyticsParam analyticsParam) {
    GroupByQuery query = new GroupByQuery();
    query.setFrom(analyticsParam.getFrom());
    query.setTo(analyticsParam.getTo());
    query.setInterval(analyticsParam.getInterval());
    query.setQuery(analyticsParam.getQuery());
    query.setField(analyticsParam.getField());
    query.setRootField("api");
    query.setRootIdentifier(api);
    if (analyticsParam.getOrder() != null) {
        GroupByQuery.Order order = new GroupByQuery.Order();
        order.setField(analyticsParam.getOrder().getField());
        order.setType(analyticsParam.getOrder().getType());
        order.setOrder(analyticsParam.getOrder().isOrder());
        query.setOrder(order);
    }
    List<Range> ranges = analyticsParam.getRanges();
    if (ranges != null) {
        Map<Double, Double> rangeMap = ranges.stream().collect(Collectors.toMap(Range::getFrom, Range::getTo));
        query.setGroups(rangeMap);
    }
    return analyticsService.execute(query);
}
Also used : GroupByQuery(io.gravitee.management.model.analytics.query.GroupByQuery) Range(io.gravitee.management.rest.resource.param.Range)

Aggregations

GroupByQuery (io.gravitee.management.model.analytics.query.GroupByQuery)2 Range (io.gravitee.management.rest.resource.param.Range)2