Skip to content

Commit f14ba87

Browse files
authored
Merge pull request #133 from Zoncovsky/fix/update-link-in-performance-button-slack
Implement performance action URL method in SlackNotificationService
2 parents ba397bd + c4440d6 commit f14ba87

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

app/controllers/errors_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ def index
6868
@q.result.includes(:project).except(:order)
6969
.joins("LEFT JOIN (#{subquery_sql}) AS impact_counts ON impact_counts.issue_id = issues.id")
7070
.order(Arel.sql("impact_counts.cnt #{dir} NULLS LAST"))
71-
elsif sort_param.present?
71+
elsif sort_param.present?
7272
@q.result.includes(:project)
73-
else
73+
else
7474
@q.result.includes(:project).severity_ordered
75-
end
75+
end
7676

7777
# Use pagy_countless to skip the expensive SELECT COUNT(*) on millions of rows.
7878
# Trade-off: we don't show "Page X of Y" or total count in pagination.

app/services/slack_notification_service.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ def project_url
7474
"#{host}/#{@project.slug}"
7575
end
7676

77+
def performance_action_url(target)
78+
return "#{project_url}/performance" if target.blank? || target == "Unknown"
79+
"#{project_url}/performance/actions/#{URI.encode_www_form_component(target)}"
80+
end
81+
7782
def error_url(issue, tab: nil, event_id: nil)
7883
q = []
7984
q << "tab=#{tab}" if tab
@@ -145,7 +150,7 @@ def build_performance_blocks(event, payload)
145150
{
146151
type: "actions",
147152
elements: [
148-
{ type: "button", text: { type: "plain_text", text: "View Performance", emoji: true }, url: "#{project_url}/performance", style: "primary" }
153+
{ type: "button", text: { type: "plain_text", text: "View Performance", emoji: true }, url: performance_action_url(endpoint), style: "primary" }
149154
]
150155
}
151156
]
@@ -172,7 +177,7 @@ def build_n_plus_one_blocks(payload)
172177
{
173178
type: "actions",
174179
elements: [
175-
{ type: "button", text: { type: "plain_text", text: "View Queries", emoji: true }, url: "#{project_url}/performance", style: "primary" }
180+
{ type: "button", text: { type: "plain_text", text: "View Queries", emoji: true }, url: performance_action_url(controller_action), style: "primary" }
176181
]
177182
}
178183
]
@@ -373,7 +378,7 @@ def build_performance_message(event, payload)
373378
{
374379
type: "button",
375380
text: "View Performance",
376-
url: "#{project_url}/performance",
381+
url: performance_action_url(event.target.presence || payload["target"] || payload["controller_action"] || event.request_path),
377382
style: "primary"
378383
}
379384
],
@@ -435,7 +440,7 @@ def build_n_plus_one_message(payload)
435440
{
436441
type: "button",
437442
text: "View Queries",
438-
url: "#{project_url}/performance",
443+
url: performance_action_url(controller_action),
439444
style: "primary"
440445
}
441446
],

0 commit comments

Comments
 (0)