in treeherder/perf/models.py [0:0]
def autodetermine_status(self, alert_model=None):
summary_class = self.__class__
if not alert_model:
alert_model = PerformanceAlert
alerts = alert_model.objects.filter(summary=self) | alert_model.objects.filter(
related_summary=self
)
# if no alerts yet, we'll say untriaged
if not alerts:
return summary_class.UNTRIAGED
# if any untriaged, then set to untriaged
if any(alert.status == alert_model.UNTRIAGED for alert in alerts):
return summary_class.UNTRIAGED
# if the summary's status is IMPROVEMENT, but a regression is
# reassigned to that summary then set the summary's status to untriaged
# and change all acknowledged statuses to untriaged
if self.status == summary_class.IMPROVEMENT:
if any(
alert.status == alert_model.REASSIGNED and alert.is_regression for alert in alerts
):
acknowledged_alerts = [
alert for alert in alerts if alert.status == alert_model.ACKNOWLEDGED
]
for alert in acknowledged_alerts:
alert.status = alert_model.UNTRIAGED
alert.save()
return summary_class.UNTRIAGED
# if all invalid, then set to invalid
if all(alert.status == alert_model.INVALID for alert in alerts):
return summary_class.INVALID
# otherwise filter out invalid alerts
alerts = [a for a in alerts if a.status != alert_model.INVALID]
# if there are any "acknowledged" alerts, then set to investigating
# if not one of the resolved statuses and there are regressions,
# otherwise we'll say it's an improvement
if any(alert.status == alert_model.ACKNOWLEDGED for alert in alerts):
if all(
not alert.is_regression
for alert in alerts
if alert.status == alert_model.ACKNOWLEDGED
or (alert.status == alert_model.REASSIGNED and alert.related_summary.id == self.id)
):
return summary_class.IMPROVEMENT
elif self.status not in (
summary_class.IMPROVEMENT,
summary_class.INVESTIGATING,
summary_class.WONTFIX,
summary_class.FIXED,
summary_class.BACKED_OUT,
):
return summary_class.INVESTIGATING
# keep status if one of the investigating ones
return self.status
# at this point, we've determined that this is a summary with no valid
# alerts of its own: all alerts should be either reassigned,
# downstream, or invalid (but not all invalid, that case is covered
# above)
if any(alert.status == alert_model.REASSIGNED for alert in alerts):
return summary_class.REASSIGNED
return summary_class.DOWNSTREAM