gjm comments on Open Thread Feb 29 - March 6, 2016 - Less Wrong

4 Post author: Elo 28 February 2016 10:11PM

You are viewing a comment permalink. View the original post to see all comments and the full post content.

Comments (285)

You are viewing a single comment's thread. Show more comments above.

Comment author: gjm 02 March 2016 03:12:41PM 2 points [-]

Yup, it's pretty horrible. But on the face of it -- I know that appearances can deceive -- it seems like you could iterate (inefficiently, but it's not like this is going to be done often) over all the votes with a given voter-ID as in the "slow" case of user_downvote_karma and call Vote.vote with dir=None as defined in vote.py for each. Something along these lines, though it probably consists entirely of bugs:

from r2.models import Account, Link, Vote
user = Account._by_name('Eugine\_Nier')
# list() to make sure enumeration is done before we start changing the votes
# (dunno if we actually need to do that)
votee_ids = list([v.c._thing2_id for v in Vote._query(Vote.c._thing1_id == user._id)])
# dir = None to remove a vote
# ip = None because ip isn't needed when not creating a new vote
for votee_id in votee_ids: Vote.vote(user, Link._byID(votee_id), None, None)