Skip to content
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 @@ -21,6 +21,7 @@
import org.hypertrace.gateway.service.v1.common.Expression;
import org.hypertrace.gateway.service.v1.common.Filter;
import org.hypertrace.gateway.service.v1.common.TimeAggregation;
import org.hypertrace.gateway.service.v1.explore.ExploreRequest.Builder;
import org.hypertrace.graphql.explorer.request.ExploreRequest;
import org.hypertrace.graphql.explorer.schema.argument.IntervalArgument;
import org.hypertrace.graphql.metric.request.MetricAggregationRequest;
Expand Down Expand Up @@ -58,23 +59,31 @@ Single<org.hypertrace.gateway.service.v1.explore.ExploreRequest> buildRequest(
this.filterConverter.convert(request.filterArguments()),
this.buildAnyAggregations(request),
this.buildAnyTimeAggregations(request),
(attributes, orderBys, groupBys, filter, aggregations, series) ->
org.hypertrace.gateway.service.v1.explore.ExploreRequest.newBuilder()
.setContext(request.scope())
.setStartTimeMillis(request.timeRange().startTime().toEpochMilli())
.setEndTimeMillis(request.timeRange().endTime().toEpochMilli())
.addAllSelection(attributes)
.addAllSelection(aggregations)
.addAllTimeAggregation(series)
.addAllOrderBy(orderBys)
.addAllGroupBy(groupBys)
.setLimit(request.limit())
.setIncludeRestGroup(request.includeRest())
.setOffset(request.offset())
.setFilter(filter)
.setSpaceId(request.spaceId().orElse("")) // String proto default value
.setGroupLimit(request.groupLimit().orElse(0)) // Int proto default value
.build());
(attributes, orderBys, groupBys, filter, aggregations, series) -> {
Builder builder =
org.hypertrace.gateway.service.v1.explore.ExploreRequest.newBuilder()
.setContext(request.scope())
.addAllSelection(attributes)
.addAllSelection(aggregations)
.addAllTimeAggregation(series)
.addAllOrderBy(orderBys)
.addAllGroupBy(groupBys)
.setLimit(request.limit())
.setIncludeRestGroup(request.includeRest())
.setOffset(request.offset())
.setFilter(filter)
.setSpaceId(request.spaceId().orElse("")) // String proto default value
.setGroupLimit(request.groupLimit().orElse(0)); // Int proto default value
request
.timeRange()
.ifPresent(
timeRangeArgument -> {
builder.setStartTimeMillis(timeRangeArgument.startTime().toEpochMilli());
builder.setEndTimeMillis(timeRangeArgument.startTime().toEpochMilli());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be timeRangeArgument.endTime().toEpochMilli()?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow good eye @skjindal93

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be timeRangeArgument.endTime().toEpochMilli()?

Absolutely, thanks for spotting!
#145

});

return builder.build();
});
}

private Single<Set<Expression>> buildAnyAggregations(ExploreRequest exploreRequest) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,8 @@ public Single<ExploreRequest> build(
.deserializePrimitive(arguments, OffsetArgument.class)
.orElse(DEFAULT_OFFSET);

TimeRangeArgument timeRange =
this.argumentDeserializer
.deserializeObject(arguments, TimeRangeArgument.class)
.orElseThrow();
Optional<TimeRangeArgument> timeRange =
this.argumentDeserializer.deserializeObject(arguments, TimeRangeArgument.class);

List<AggregatableOrderArgument> requestedOrders =
this.argumentDeserializer
Expand Down Expand Up @@ -141,7 +139,7 @@ public Single<ExploreRequest> build(
public Single<ExploreRequest> build(
GraphQlRequestContext requestContext,
String explorerScope,
TimeRangeArgument timeRange,
Optional<TimeRangeArgument> timeRange,
Optional<String> spaceId,
int limit,
int offset,
Expand Down Expand Up @@ -214,7 +212,7 @@ private Set<AttributeExpression> resolveGroupByExpressions(GroupByArgument group
private static class DefaultExploreRequest implements ExploreRequest {
GraphQlRequestContext context;
String scope;
TimeRangeArgument timeRange;
Optional<TimeRangeArgument> timeRange;
int limit;
int offset;
Set<AttributeRequest> attributeRequests;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public interface ExploreRequest extends ContextualRequest {
String scope();

TimeRangeArgument timeRange();
Optional<TimeRangeArgument> timeRange();

int limit();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Single<ExploreRequest> build(
Single<ExploreRequest> build(
GraphQlRequestContext requestContext,
String explorerScope,
TimeRangeArgument timeRange,
Optional<TimeRangeArgument> timeRange,
Optional<String> spaceId,
int limit,
int offset,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public interface ExplorerSchema {
ExploreResultSet explore(
@Deprecated @GraphQLName(ExplorerContextArgument.ARGUMENT_NAME) ExplorerContext context,
@GraphQLName(ExplorerScopeArgument.ARGUMENT_NAME) String scope,
@GraphQLName(TimeRangeArgument.ARGUMENT_NAME) @GraphQLNonNull TimeRangeArgument timeRange,
@GraphQLName(TimeRangeArgument.ARGUMENT_NAME) TimeRangeArgument timeRange,
@GraphQLName(SpaceArgument.ARGUMENT_NAME) String space,
@GraphQLName(LimitArgument.ARGUMENT_NAME) int limit,
@GraphQLName(OffsetArgument.ARGUMENT_NAME) int offset,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private Single<ExploreRequest> buildRequest(GraphQlRequestContext context) {
attributeRequest ->
new ActiveSpaceExploreRequest(
context,
new FixedTimeRange(this.clock.instant()),
Optional.of(new FixedTimeRange(this.clock.instant())),
attributeRequest,
this.metricAggregationRequestBuilder.build(
attributeRequest.attributeExpressionAssociation(),
Expand Down Expand Up @@ -153,14 +153,14 @@ private static class ActiveSpaceExploreRequest implements ExploreRequest {
Optional<String> spaceId = Optional.empty();
Optional<Integer> groupLimit = Optional.of(MAX_SPACES);

TimeRangeArgument timeRange;
Optional<TimeRangeArgument> timeRange;
Set<MetricAggregationRequest> aggregationRequests;
List<ExploreOrderArgument> orderArguments;
Set<AttributeRequest> groupByAttributeRequests;

ActiveSpaceExploreRequest(
GraphQlRequestContext context,
TimeRangeArgument timeRange,
Optional<TimeRangeArgument> timeRange,
AttributeRequest spaceIdRequest,
MetricAggregationRequest spaceIdCountRequest) {
this.context = context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ void makesAppropriateRequest() {
&& request.offset() == 0
&& request
.timeRange()
.get()
.startTime()
.equals(Instant.parse("2021-01-01T00:00:00.00Z"))
&& request.timeRange().endTime().equals(this.mockEndTime)
&& request.timeRange().get().endTime().equals(this.mockEndTime)
&& request.attributeRequests().isEmpty()
&& request.aggregationRequests().equals(Set.of(this.mockSpaceCountRequest))
&& request.orderArguments().size() == 1
Expand Down