Skip to content

Commit

Permalink
Merge pull request #894 from trishnaguha/critical-update
Browse files Browse the repository at this point in the history
Disable AutoPush for critical update if it receives negative karma
  • Loading branch information
bowlofeggs authored Sep 17, 2016
2 parents ec09d01 + b1f7100 commit a9e6f39
Show file tree
Hide file tree
Showing 2 changed files with 390 additions and 1 deletion.
18 changes: 17 additions & 1 deletion bodhi/server/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1658,7 +1658,11 @@ def check_karma_thresholds(self, db, agent):
"""Check if we have reached either karma threshold, and call set_request if necessary"""
if not self.locked:
if self.status is UpdateStatus.testing:
if self.stable_karma not in (0, None) and self.karma >= self.stable_karma:
# If critical update receives negative karma disable autopush
if self.critpath and self.autokarma and self.has_negative_karma:
log.info("Disabling Auto Push since the critical update has negative karma")
self.autokarma = False
elif self.stable_karma not in (0, None) and self.karma >= self.stable_karma:
if self.autokarma:
log.info("Automatically marking %s as stable" % self.title)
self.set_request(db, UpdateRequest.stable, agent)
Expand Down Expand Up @@ -1712,6 +1716,18 @@ def last_modified(self):
possibilities.sort() # Sort smallest to largest (oldest to newest)
return possibilities[-1] # Return the last one

@property
def has_negative_karma(self):
"""Check for negative karma, Returns True if the update has negative karma"""
feedback = defaultdict(int)
for comment in self.comments:
if not comment.anonymous:
feedback[comment.user.name] = comment.karma
for karma in feedback.values():
if karma < 0:
return True
return False

@property
def critpath_approved(self):
""" Return whether or not this critpath update has been approved """
Expand Down
Loading

0 comments on commit a9e6f39

Please sign in to comment.