Example #1
0
 def incr_karma(self, kind, sr, amt):
     prop = '%s_%s_karma' % (sr.name, kind)
     if hasattr(self, prop):
         self._incr(prop, amt)
     else:
         default_val = self.karma(kind, sr)
         setattr(self, prop, default_val + amt)
         self._commit()
     from r2.lib.user_stats import expire_user_change  # prevent circular import
     expire_user_change(self)
Example #2
0
    def incr_karma(self, kind, sr, amt_up, amt_down):
        def do_incr(prop, amt):
            if hasattr(self, prop):
                self._incr(prop, amt)
            else:
                assert self._loaded
                setattr(self, prop, amt)
                self._commit()

        if amt_up:
            do_incr('karma_ups_{0}_{1}'.format(kind, sr.name), amt_up)
        if amt_down:
            do_incr('karma_downs_{0}_{1}'.format(kind, sr.name), amt_down)

        from r2.lib.user_stats import expire_user_change  # prevent circular import
        expire_user_change(self)
Example #3
0
    def incr_karma(self, kind, sr, amt_up, amt_down):
        def do_incr(prop, amt):
            if hasattr(self, prop):
                self._incr(prop, amt)
            else:
                assert self._loaded
                setattr(self, prop, amt)
                self._commit()

        if amt_up:
            do_incr('karma_ups_{0}_{1}'.format(kind, sr.name), amt_up)
        if amt_down:
            do_incr('karma_downs_{0}_{1}'.format(kind, sr.name), amt_down)

        from r2.lib.user_stats import expire_user_change  # prevent circular import
        expire_user_change(self)