Skip to content

Added build method for explore-request-builder #138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,6 @@ public Single<ExploreRequest> build(
.map(this.scopeStringTranslator::fromExternal)
.orElseThrow();

return this.build(requestContext, explorerScope, arguments, selectionSet);
}

private Single<ExploreRequest> build(
GraphQlRequestContext requestContext,
String explorerScope,
Map<String, Object> arguments,
DataFetchingFieldSelectionSet selectionSet) {

int limit =
this.argumentDeserializer
.deserializePrimitive(arguments, LimitArgument.class)
Expand Down Expand Up @@ -120,9 +111,6 @@ private Single<ExploreRequest> build(
Optional<String> spaceId =
this.argumentDeserializer.deserializePrimitive(arguments, SpaceArgument.class);

Set<AttributeExpression> groupByExpressions =
groupBy.map(this::resolveGroupByExpressions).orElseGet(Collections::emptySet);

Optional<IntervalArgument> intervalArgument =
this.argumentDeserializer.deserializeObject(arguments, IntervalArgument.class);

Expand All @@ -134,6 +122,39 @@ private Single<ExploreRequest> build(
this.selectionRequestBuilder.getAggregationSelections(
requestContext, explorerScope, selectionSet);

return build(
requestContext,
explorerScope,
timeRange,
spaceId,
limit,
offset,
requestedFilters,
requestedOrders,
groupBy,
intervalArgument,
attributeSelections,
aggregationSelections);
}

@Override
public Single<ExploreRequest> build(
GraphQlRequestContext requestContext,
String explorerScope,
TimeRangeArgument timeRange,
Optional<String> spaceId,
int limit,
int offset,
List<FilterArgument> requestedFilters,
List<AggregatableOrderArgument> requestedOrders,
Optional<GroupByArgument> groupBy,
Optional<IntervalArgument> intervalArgument,
Single<Set<AttributeRequest>> attributeSelections,
Single<Set<MetricAggregationRequest>> aggregationSelections) {

Set<AttributeExpression> groupByExpressions =
groupBy.map(this::resolveGroupByExpressions).orElseGet(Collections::emptySet);

Single<List<ExploreOrderArgument>> orderArguments =
this.exploreOrderArgumentBuilder.buildList(requestContext, explorerScope, requestedOrders);

Expand All @@ -151,8 +172,8 @@ private Single<ExploreRequest> build(
requestContext,
explorerScope,
timeRange,
limit,
offset,
limit > 0 ? limit : DEFAULT_LIMIT,
offset >= 0 ? offset : DEFAULT_OFFSET,
attributes,
aggregations,
orders,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,36 @@

import graphql.schema.DataFetchingFieldSelectionSet;
import io.reactivex.rxjava3.core.Single;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import org.hypertrace.core.graphql.common.request.AttributeRequest;
import org.hypertrace.core.graphql.common.schema.arguments.TimeRangeArgument;
import org.hypertrace.core.graphql.common.schema.results.arguments.filter.FilterArgument;
import org.hypertrace.core.graphql.context.GraphQlRequestContext;
import org.hypertrace.graphql.explorer.schema.argument.GroupByArgument;
import org.hypertrace.graphql.explorer.schema.argument.IntervalArgument;
import org.hypertrace.graphql.metric.request.MetricAggregationRequest;
import org.hypertrace.graphql.metric.schema.argument.AggregatableOrderArgument;

public interface ExploreRequestBuilder {
Single<ExploreRequest> build(
GraphQlRequestContext context,
Map<String, Object> arguments,
DataFetchingFieldSelectionSet selectionSet);

Single<ExploreRequest> build(
GraphQlRequestContext requestContext,
String explorerScope,
TimeRangeArgument timeRange,
Optional<String> spaceId,
int limit,
int offset,
List<FilterArgument> requestedFilters,
List<AggregatableOrderArgument> requestedOrders,
Optional<GroupByArgument> groupBy,
Optional<IntervalArgument> intervalArgument,
Single<Set<AttributeRequest>> attributeSelections,
Single<Set<MetricAggregationRequest>> aggregationSelections);
}