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

Simplify and speed up slack rendering #1105

Merged
merged 3 commits into from
Jan 10, 2023

Conversation

Konstantinov-Innokentii
Copy link
Member

@Konstantinov-Innokentii Konstantinov-Innokentii commented Jan 9, 2023

What this PR does

This PR simplify and speed up slack rendering.

For alert group with large amount of alerts query self.alert_group.alerts.filter(is_resolve_signal=False) took a several seconds to execute, since is_resolve_signalnot indexed. On the other hand, that query makes no sence, because anyway we using all alerts, when rendering their count in slack:

 def _get_text_alert_grouped(self):
        alert_count = self.alert_group.alerts.count()
        link = self.alert_group.web_link

        text = (
            f":package: Showing the last alert only out of {alert_count} total. "
            f"Visit <{link}|the plugin page> to see them all."
        )

        return text

So, I decided to remove filtering by is_resolve_signal in that case and leave only one alert_group.alerts.count() query.

Also, I checked that we have no any organizations which installed slack not via granular permissions and removed this check, which produced 4 SELECTs. For OSS slack we provide app manifest, so self.alert_group.channel.organization.slack_team_identity.installed_via_granular_permissions check can be safely removed.

@Konstantinov-Innokentii Konstantinov-Innokentii requested a review from a team January 9, 2023 05:20
Copy link
Member

@vstpme vstpme left a comment

Choose a reason for hiding this comment

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

LGTM

@Konstantinov-Innokentii Konstantinov-Innokentii deleted the speed_up_slack_rendering branch January 10, 2023 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants