Skip to content
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

fix(usage): pull usage from environment source rather than args #4824

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -2,6 +2,7 @@

import com.linkedin.datahub.graphql.UsageStatsKey;

import com.linkedin.datahub.graphql.generated.Entity;
import com.linkedin.datahub.graphql.types.LoadableType;
import com.linkedin.pegasus2avro.usage.UsageQueryResult;
import com.linkedin.usage.UsageTimeRange;
Expand All @@ -27,7 +28,7 @@ public class UsageTypeResolver implements DataFetcher<CompletableFuture<UsageQue
public CompletableFuture<UsageQueryResult> get(DataFetchingEnvironment environment) {
final DataLoader<UsageStatsKey, UsageQueryResult> loader = environment.getDataLoaderRegistry().getDataLoader("UsageQueryResult");

String resource = environment.getArgument("resource");
final String resource = ((Entity) environment.getSource()).getUrn();
UsageTimeRange duration = UsageTimeRange.valueOf(environment.getArgument("range"));

UsageStatsKey key = new UsageStatsKey(resource, duration);
Expand Down
2 changes: 1 addition & 1 deletion datahub-graphql-core/src/main/resources/entity.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ type Dataset implements EntityWithRelationships & Entity {
"""
Statistics about how this Dataset is used
"""
usageStats(resource: String!, range: TimeRange): UsageQueryResult
Copy link
Contributor

Choose a reason for hiding this comment

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

seems like a backwards incompatible change? old callers will fail now?

usageStats(range: TimeRange): UsageQueryResult

"""
Profile Stats resource that retrieves the events in a previous unit of time in descending order
Expand Down
2 changes: 1 addition & 1 deletion datahub-web-react/src/graphql/dataset.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ query getDataset($urn: String!) {
container {
...entityContainer
}
usageStats(resource: $urn, range: MONTH) {
Copy link
Contributor

Choose a reason for hiding this comment

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

backwards incompatible change?

usageStats(range: MONTH) {
buckets {
bucket
duration
Expand Down