Skip to content

Highlight duplicated alert summaries for the same revision #8585

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tests/ui/mock/alert_summaries.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
}
],
"related_alerts": [],
"duplicated_summaries_ids": [],
"status": 0,
"bug_number": null,
"bug_updated": null,
Expand Down Expand Up @@ -223,6 +224,7 @@
}
],
"related_alerts": [],
"duplicated_summaries_ids": [],
"status": 0,
"bug_number": null,
"bug_updated": null,
Expand Down Expand Up @@ -358,6 +360,7 @@
}
],
"related_alerts": [],
"duplicated_summaries_ids": [],
"status": 0,
"bug_number": null,
"bug_updated": null,
Expand Down
2 changes: 2 additions & 0 deletions tests/webapp/api/test_performance_alertsummary_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def test_alert_summaries_get(
"push_timestamp",
"prev_push_revision",
"performance_tags",
"duplicated_summaries_ids",
}
assert len(resp.json()["results"][0]["alerts"]) == 1
assert set(resp.json()["results"][0]["alerts"][0].keys()) == {
Expand Down Expand Up @@ -174,6 +175,7 @@ def test_alert_summaries_get_onhold(
"push_timestamp",
"prev_push_revision",
"performance_tags",
"duplicated_summaries_ids",
}
assert len(resp.json()["results"][0]["alerts"]) == 1
assert set(resp.json()["results"][0]["alerts"][0].keys()) == {
Expand Down
9 changes: 9 additions & 0 deletions treeherder/webapp/api/performance_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ class PerformanceAlertSummarySerializer(serializers.ModelSerializer):
queryset=User.objects.all(),
)
assignee_email = serializers.SerializerMethodField()
duplicated_summaries_ids = serializers.SerializerMethodField()
# marking these fields as readonly, the user should not be modifying them
# (after the item is first created, where we don't use this serializer
# class)
Expand All @@ -310,6 +311,13 @@ def update(self, instance, validated_data):
def get_assignee_email(self, performance_alert_summary):
return getattr(performance_alert_summary.assignee, "email", None)

def get_duplicated_summaries_ids(self, performance_alert_summary):
return (
PerformanceAlertSummary.objects.filter(push=performance_alert_summary.push)
.exclude(id=performance_alert_summary.id)
.values_list("id", flat=True)
)

class Meta:
model = PerformanceAlertSummary
fields = [
Expand All @@ -336,6 +344,7 @@ class Meta:
"assignee_username",
"assignee_email",
"performance_tags",
"duplicated_summaries_ids",
]


Expand Down
19 changes: 19 additions & 0 deletions ui/perfherder/alerts/AlertHeader.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { Link } from 'react-router-dom';
import {
UncontrolledDropdown,
DropdownMenu,
Expand Down Expand Up @@ -240,6 +241,24 @@ const AlertHeader = ({
/>
</Col>
</Row>
{alertSummary.duplicated_summaries_ids.length > 0 && (
<Row>
Duplicated summaries:
{alertSummary.duplicated_summaries_ids.map((id, index) => (
<Link
className="text-dark mr-1"
target="_blank"
to={`./alerts?id=${id}&hideDwnToInv=0`}
id={`duplicated alert summary ${id.toString()} `}
style={{ marginLeft: '5px' }}
>
Alert #{id}
{alertSummary.duplicated_summaries_ids.length - 1 !== index &&
', '}
</Link>
))}
</Row>
)}
<Row>
{performanceTags.length > 0 && (
<Col className="p-0" xs="auto">
Expand Down