-
-
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(escalating_issues): Improve code and typing #47822
Conversation
@@ -39,33 +38,33 @@ | |||
ParsedGroupsCount = Dict[int, GroupCount] | |||
|
|||
|
|||
def query_groups_past_counts(groups: List[Group]) -> List[GroupsCountResponse]: | |||
def query_groups_past_counts(groups: Sequence[Group]) -> List[GroupsCountResponse]: |
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.
A best practice @asottile-sentry encouraged me to follow is to have loose typing as input and tighter typing on returns.
all_results = [] | ||
offset = 0 | ||
while True: | ||
query = _generate_query(project_ids, group_ids, offset, start_date, end_date) | ||
request = Request(dataset=Dataset.Events.value, app_id=REFERRER, query=query) | ||
results = raw_snql_query(request, referrer=REFERRER)["data"] | ||
if not results: |
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.
This solves an N+1 perf issue Oliver noticed on the other PR.
@@ -36,7 +36,7 @@ def handle_archived_until_escalating( | |||
metrics.incr("group.archived_until_escalating", skip_internal=True) | |||
for group in group_list: | |||
remove_group_from_inbox(group, action=GroupInboxRemoveAction.IGNORED, user=acting_user) | |||
generate_and_save_forecasts(list(group_list)) | |||
generate_and_save_forecasts(group_list) |
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.
This is an actual bug that went unnoticed.
The PR #47820 will solve that this slipped through.
These are various code improvements and it improves the readability of #47626