Skip to content

Commit 07236d2

Browse files
Highlight duplicated alert summaries for the same revision (#8585)
* Display duplicated summaries in Alerts View * Address change request * Filter summaries by framework
1 parent 91be321 commit 07236d2

4 files changed

Lines changed: 35 additions & 0 deletions

File tree

tests/ui/mock/alert_summaries.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@
136136
}
137137
],
138138
"related_alerts": [],
139+
"duplicated_summaries_ids": [],
139140
"status": 0,
140141
"bug_number": null,
141142
"bug_updated": null,
@@ -223,6 +224,7 @@
223224
}
224225
],
225226
"related_alerts": [],
227+
"duplicated_summaries_ids": [],
226228
"status": 0,
227229
"bug_number": null,
228230
"bug_updated": null,
@@ -358,6 +360,7 @@
358360
}
359361
],
360362
"related_alerts": [],
363+
"duplicated_summaries_ids": [],
361364
"status": 0,
362365
"bug_number": null,
363366
"bug_updated": null,

tests/webapp/api/test_performance_alertsummary_api.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def test_alert_summaries_get(
9595
"prev_push_revision",
9696
"original_prev_push_revision",
9797
"performance_tags",
98+
"duplicated_summaries_ids",
9899
}
99100
assert len(resp.json()["results"][0]["alerts"]) == 1
100101
assert set(resp.json()["results"][0]["alerts"][0].keys()) == {
@@ -176,6 +177,7 @@ def test_alert_summaries_get_onhold(
176177
"prev_push_revision",
177178
"original_prev_push_revision",
178179
"performance_tags",
180+
"duplicated_summaries_ids",
179181
}
180182
assert len(resp.json()["results"][0]["alerts"]) == 1
181183
assert set(resp.json()["results"][0]["alerts"][0].keys()) == {

treeherder/webapp/api/performance_serializers.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ class PerformanceAlertSummarySerializer(serializers.ModelSerializer):
300300
queryset=User.objects.all(),
301301
)
302302
assignee_email = serializers.SerializerMethodField()
303+
duplicated_summaries_ids = serializers.SerializerMethodField()
303304
# marking these fields as readonly, the user should not be modifying them
304305
# (after the item is first created, where we don't use this serializer
305306
# class)
@@ -317,6 +318,15 @@ def update(self, instance, validated_data):
317318
def get_assignee_email(self, performance_alert_summary):
318319
return getattr(performance_alert_summary.assignee, "email", None)
319320

321+
def get_duplicated_summaries_ids(self, performance_alert_summary):
322+
return (
323+
PerformanceAlertSummary.objects.filter(
324+
push=performance_alert_summary.push, framework=performance_alert_summary.framework
325+
)
326+
.exclude(id=performance_alert_summary.id)
327+
.values_list("id", flat=True)
328+
)
329+
320330
class Meta:
321331
model = PerformanceAlertSummary
322332
fields = [
@@ -344,6 +354,7 @@ class Meta:
344354
"assignee_username",
345355
"assignee_email",
346356
"performance_tags",
357+
"duplicated_summaries_ids",
347358
]
348359

349360

ui/perfherder/alerts/AlertHeader.jsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { useState } from 'react';
22
import PropTypes from 'prop-types';
3+
import { Link } from 'react-router-dom';
34
import {
45
UncontrolledDropdown,
56
DropdownMenu,
@@ -230,6 +231,24 @@ const AlertHeader = ({
230231
<span className="px-2">Revisions have been modified.</span>
231232
)}
232233
</Row>
234+
{alertSummary.duplicated_summaries_ids.length > 0 && (
235+
<Row>
236+
Duplicated summaries:
237+
{alertSummary.duplicated_summaries_ids.map((id, index) => (
238+
<Link
239+
className="text-dark mr-1"
240+
target="_blank"
241+
to={`./alerts?id=${id}&hideDwnToInv=0`}
242+
id={`duplicated alert summary ${id.toString()} `}
243+
style={{ marginLeft: '5px' }}
244+
>
245+
Alert #{id}
246+
{alertSummary.duplicated_summaries_ids.length - 1 !== index &&
247+
', '}
248+
</Link>
249+
))}
250+
</Row>
251+
)}
233252
<Row>
234253
{performanceTags.length > 0 && (
235254
<Col className="p-0" xs="auto">

0 commit comments

Comments
 (0)