def add_rating(self, rating=0): ''' Add a rating for a SavedMacro. Returns the rating rounded to the largest half star.''' #logging.debug(" Adding a rating of %s" % rating) # Make sure it's a valid rating. if (rating < 1) or (rating > MAX_RATING): return self.get_rating() # Need to update two counters: num_rates and rating. else: num_rates = incr_count(self.entity.link_id, 'num_rates', update_count, entity_val=self.entity.num_rates) rating = incr_count(self.entity.link_id, 'rating', update_count, incr_amt=rating, entity_val=self.entity.rating) return self.get_rating(rating, num_rates)
def add_to_view_count(self): ''' Update view count for a SavedMacro.''' #logging.debug(" Incrementing view count.") # Execute increment, accounting for older objects without a # view field. try: init_val = self.entity.views except: init_val = 0 ret = incr_count(self.entity.link_id, 'views', update_count, entity_val=init_val) return ret
def add_to_send_count(self): ''' Update send count for a SavedMacro.''' #logging.debug(" Incrementing send count.") # Execute increment, accounting for older objects without a # send field. try: init_val = self.entity.sends except: init_val = 0 ret = incr_count(self.entity.link_id, 'sends', update_count, entity_val=init_val) return ret