Skip to content

Commit

Permalink
Disable AutoPush for critical update if it receives negative karma
Browse files Browse the repository at this point in the history
  • Loading branch information
trishnaguha committed Sep 17, 2016
1 parent c02fd26 commit b1f7100
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
Expand Up @@ -1653,7 +1653,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 @@ -1707,6 +1711,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

0 comments on commit b1f7100

Please sign in to comment.