Skip to content

Commit

Permalink
ref: avoid accessing options at module scope to build logo url (#79207)
Browse files Browse the repository at this point in the history
(this accessed the database at module scope to look up the option value)

<!-- Describe your PR here. -->
  • Loading branch information
asottile-sentry authored Oct 16, 2024
1 parent 9eb3355 commit 68e5b1d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/sentry/integrations/metric_alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"percentage(sessions_crashed, sessions)": "% sessions crash free rate",
"percentage(users_crashed, users)": "% users crash free rate",
}
LOGO_URL = absolute_uri(get_asset_url("sentry", "images/sentry-email-avatar.png"))
# These should be the same as the options in the frontend
# COMPARISON_DELTA_OPTIONS
TEXT_COMPARISON_DELTA = {
Expand All @@ -39,6 +38,10 @@
}


def logo_url() -> str:
return absolute_uri(get_asset_url("sentry", "images/sentry-email-avatar.png"))


def get_metric_count_from_incident(incident: Incident) -> str:
"""Returns the current or last count of an incident aggregate."""
incident_trigger = (
Expand Down Expand Up @@ -144,7 +147,7 @@ def incident_attachment_info(
return {
"title": title,
"text": text,
"logo_url": LOGO_URL,
"logo_url": logo_url(),
"status": status,
"ts": incident.date_started,
"title_link": title_link,
Expand Down Expand Up @@ -232,7 +235,7 @@ def metric_alert_attachment_info(
return {
"title": title,
"text": text,
"logo_url": LOGO_URL,
"logo_url": logo_url(),
"status": status,
"date_started": date_started,
"last_triggered_date": last_triggered_date,
Expand Down

0 comments on commit 68e5b1d

Please sign in to comment.