From bc0fb3f61d2ad153a57e15a6fb0a1f6dfc62e488 Mon Sep 17 00:00:00 2001 From: Mattia Rizzolo Date: Thu, 21 Feb 2019 12:41:38 +0100 Subject: [PATCH] Display bounty/penalty information only if they would actually be changing anything This avoid messages like Required age reduced by 0 days because of autopkgtest that is hardly useful. Signed-off-by: Mattia Rizzolo --- britney2/policies/policy.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/britney2/policies/policy.py b/britney2/policies/policy.py index 6037baf..685bbea 100644 --- a/britney2/policies/policy.py +++ b/britney2/policies/policy.py @@ -338,18 +338,20 @@ class AgePolicy(BasePolicy): days_old = self._date_now - self._dates[source_name][1] min_days = self._min_days[urgency] for bounty in excuse.bounty: - self.logger.info('Applying bounty for %s granted by %s: %d days', - source_name, bounty, excuse.bounty[bounty]) - excuse.addhtml('Required age reduced by %d days because of %s' % - (excuse.bounty[bounty], bounty)) - min_days -= excuse.bounty[bounty] + if excuse.bounty[bounty]: + self.logger.info('Applying bounty for %s granted by %s: %d days', + source_name, bounty, excuse.bounty[bounty]) + excuse.addhtml('Required age reduced by %d days because of %s' % + (excuse.bounty[bounty], bounty)) + min_days -= excuse.bounty[bounty] if urgency not in self._penalty_immune_urgencies: for penalty in excuse.penalty: - self.logger.info('Applying penalty for %s given by %s: %d days', - source_name, penalty, excuse.penalty[penalty]) - excuse.addhtml('Required age increased by %d days because of %s' % - (excuse.penalty[penalty], penalty)) - min_days += excuse.penalty[penalty] + if excuse.penalty[penalty]: + self.logger.info('Applying penalty for %s given by %s: %d days', + source_name, penalty, excuse.penalty[penalty]) + excuse.addhtml('Required age increased by %d days because of %s' % + (excuse.penalty[penalty], penalty)) + min_days += excuse.penalty[penalty] # the age in BOUNTY_MIN_AGE can be higher than the one associated with # the real urgency, so don't forget to take it into account