Done.


On Mon, Aug 19, 2013 at 5:37 PM, Lucas Sloan <
predictably.defenestrated@gmail.com> wrote:

> Ok, cool.  Thanks for showing me that,
>
>
> On Monday, August 19, 2013, keyist wrote:
>
>> In r2/r2/models/link.py:
>>
>> > @@ -1038,6 +1053,11 @@ def reply_costs_karma(self):
>> >              return True
>> >          return self.try_parent(lambda p: p.reply_costs_karma, False)
>> >
>> > +    def incr_descendant_karma(self, amount):
>> > +        self._incr('_descendant_karma', amount)
>> > +        if hasattr(self, 'parent_id') and self.parent_id:
>> > +            Comment._byID(self.parent_id).incr_descendant_karma(amount)
>> > +
>>
>> You can execute an UPDATE statement as per r2/r2/models/report.py<https://github.com/tricycle/lesswrong/blob/1233c31f00dcd1592b65361621c323b4ec64ca31/r2/r2/models/report.py#L480>
>> .
>>
>> Something like UPDATE %(table)s SET descendant_karma = descendant_karma
>> + %(amount)s WHERE id IN %(self_and_ancestor_ids)s
>>
>> The benefits:
>>
>>    - one atomic UPDATE sql statement instead of having to wrap multiple
>>    ones in a transaction
>>    - the logic happens inside one method call instead of multiple
>>    invocations of incr_descendant_karma on different objects (more performant,
>>    easier to debug)
>>
>> —
>> Reply to this email directly or view it on GitHub<https://github.com/tricycle/lesswrong/pull/85/files#r5858340>
>> .
>>
>
>
> --
> "*And someday when the descendants of humanity have spread from star to
> star, they won't tell the children about the history of Ancient Earth until
> they're old enough to bear it; and when they learn they'll weep to hear
> that such a thing as Death had ever once existed!*"
>
> -Eliezer Yudkowsky
>
> "Trust me" means "I love you" <http://project-apollo.net/mos/mos114.html>
>
> "This isn't even my final form!"
>
> -Tim Hausler
>
>


-- 
"*And someday when the descendants of humanity have spread from star to
star, they won't tell the children about the history of Ancient Earth until
they're old enough to bear it; and when they learn they'll weep to hear
that such a thing as Death had ever once existed!*"

-Eliezer Yudkowsky

"Trust me" means "I love you" <http://project-apollo.net/mos/mos114.html>

"This isn't even my final form!"

-Tim Hausler