-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
ref(querybuilder): Remove params from snuba modules #76198
Merged
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
bf035f2
ref(querybuilder): Remove params from snuba modules
wmak 3775ed6
fix: tests
wmak a8487f4
fix: export
wmak 0f63a1f
fix: tests
wmak 47afd11
fix: tests
wmak f8132a4
Merge branch 'master' into wmak/ref/remove-params-from-modules
wmak a7f8565
fix merge tests
wmak fb7a5ec
Merge branch 'master' into wmak/ref/remove-params-from-modules
wmak 02cfde2
fix: test
wmak 4f23841
Merge branch 'master' into wmak/ref/remove-params-from-modules
wmak 60f46ac
ref: update the temp function
wmak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
from sentry.models.group import Group | ||
from sentry.models.project import Project | ||
from sentry.search.events.fields import get_function_alias | ||
from sentry.search.events.types import ParamsType | ||
from sentry.search.events.types import SnubaParams | ||
from sentry.snuba import discover | ||
from sentry.snuba.utils import get_dataset | ||
|
||
|
@@ -21,20 +21,20 @@ class DiscoverProcessor: | |
Processor for exports of discover data based on a provided query | ||
""" | ||
|
||
def __init__(self, organization_id, discover_query): | ||
self.projects = self.get_projects(organization_id, discover_query) | ||
self.environments = self.get_environments(organization_id, discover_query) | ||
def __init__(self, organization, discover_query): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actual changes here, had to change the param from organization_id to the organization object. And changed |
||
self.projects = self.get_projects(organization.id, discover_query) | ||
self.environments = self.get_environments(organization.id, discover_query) | ||
self.start, self.end = get_date_range_from_params(discover_query) | ||
self.params: ParamsType = { | ||
"organization_id": organization_id, | ||
"project_id": [project.id for project in self.projects], | ||
"start": self.start, | ||
"end": self.end, | ||
} | ||
self.snuba_params = SnubaParams( | ||
organization=organization, | ||
projects=self.projects, | ||
start=self.start, | ||
end=self.end, | ||
) | ||
# make sure to only include environment if any are given | ||
# an empty list DOES NOT work | ||
if self.environments: | ||
self.params["environment"] = self.environments | ||
self.snuba_params.environments = self.environments | ||
|
||
equations = discover_query.get("equations", []) | ||
self.header_fields = [get_function_alias(x) for x in discover_query["field"]] + equations | ||
|
@@ -45,7 +45,7 @@ def __init__(self, organization_id, discover_query): | |
fields=discover_query["field"], | ||
equations=equations, | ||
query=discover_query["query"], | ||
params=self.params, | ||
snuba_params=self.snuba_params, | ||
sort=discover_query.get("sort"), | ||
dataset=discover_query.get("dataset"), | ||
) | ||
|
@@ -76,10 +76,10 @@ def get_environments(organization_id, query): | |
if set(requested_environments) != set(environment_names): | ||
raise ExportError("Requested environment does not exist") | ||
|
||
return environment_names | ||
return environments | ||
|
||
@staticmethod | ||
def get_data_fn(fields, equations, query, params, sort, dataset): | ||
def get_data_fn(fields, equations, query, snuba_params, sort, dataset): | ||
dataset = get_dataset(dataset) | ||
if dataset is None: | ||
dataset = discover | ||
|
@@ -89,7 +89,7 @@ def data_fn(offset, limit): | |
selected_columns=fields, | ||
equations=equations, | ||
query=query, | ||
params=params, | ||
snuba_params=snuba_params, | ||
offset=offset, | ||
orderby=sort, | ||
limit=limit, | ||
|
@@ -112,8 +112,8 @@ def handle_fields(self, result_list): | |
i.id: i.qualified_short_id | ||
for i in Group.objects.filter( | ||
id__in=issue_ids, | ||
project__in=self.params["project_id"], | ||
project__organization_id=self.params["organization_id"], | ||
project__in=self.snuba_params.project_ids, | ||
project__organization_id=self.snuba_params.organization_id, | ||
) | ||
} | ||
for result in new_result_list: | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actual changes here, changed the param to a list of param objects so we don't need to hit the db again