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

ref(escalating_issues): Improve code and typing #47822

Merged
merged 2 commits into from
Apr 24, 2023

Conversation

armenzg
Copy link
Member

@armenzg armenzg commented Apr 24, 2023

These are various code improvements and it improves the readability of #47626

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 24, 2023
@armenzg armenzg self-assigned this Apr 24, 2023
@@ -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]:
Copy link
Member Author

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:
Copy link
Member Author

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)
Copy link
Member Author

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.

@armenzg armenzg marked this pull request as ready for review April 24, 2023 16:14
@armenzg armenzg requested review from a team and jangjodi April 24, 2023 16:14
@armenzg armenzg enabled auto-merge (squash) April 24, 2023 16:16
@armenzg armenzg merged commit 56876e6 into master Apr 24, 2023
@armenzg armenzg deleted the armenzg/escalating/minor-refactor branch April 24, 2023 16:36
@armenzg armenzg added this to the Escalating Issues V1 milestone May 2, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jun 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants