Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

batch hide and unhide API #797

Closed
wants to merge 1 commit into from

4 participants

Andrew Shu Steve Sobel Neil Williams aperson
Andrew Shu

I looked through the code, making sure it batches the Cassandra commits and updates the cached query get_hidden_links. (That code was already in class LinkHidesByAccount.)

Then executes Link._something or _unsomething to add a SaveHide relation with name='hide' for each link.

That part has a _commit() per Link, but I assume that's fine since that's how it's done in e.g. Inbox.set_unread()

Steve Sobel

I'd love to see this feature get in, but I'm not sure if reddit would suffer performance wise from having much bigger quantities of hidden posts...

a very, very common RES feature request is a bulk hide option, but I won't implement it due to the number of API hits required... this would make that a much more reasonable feature request, but I'm wondering if maybe the reason Reddit hasn't allowed a hide-many via the API is for performance reasons.

to be clear: I have no idea how it would affect performance. I'm not deeply familiar with the internals.

Neil Williams
Owner

I'm curious, what do people need batch hides/unhides for?

Andrew Shu

@honestbleeps I think it'll have a similar performance impact to the "don't show links after I've liked/disliked them" option, since likes, dislikes, and hidden seem to be stored the same way in the backend, at least from my superficial understanding.

@spladug It's nice for batch-hide in clients. E.g., a Hide All button for a page of posts.

Steve Sobel

@spladug I don't do this, but a use case for a lot of people is: view a page of content... hide all.. refresh... they want new content, and pagination isn't their bag for whatever reason... maybe because pages shuffle so much that they see lots of dupe content when they go through pages? I dunno. I just know it's an oft-requested feature... like REALLY often.

aperson

I'll have to say that this used to be my moderation method. Go through the first 100 submissions in /new, hide-all, repeat (until there's nothing left).

Neil Williams
Owner

Thanks for the pull request. After further consideration, I think I'd rather not merge this functionality and encourage such behaviour. The reason for this is that if a user has a lot of hidden links, the builder (which takes a list of links in the subreddit and determines which ones should be visible and which hidden) has to do an increasing number of backend lookups rather than getting everything it needs in one go. This would mean that users going crazy with batch hides would see their listing requests slow down the more they do so.

Neil Williams spladug closed this
Andrew Shu

@spladug All right, thanks for the explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 23, 2013
  1. Andrew Shu

    batch hide and unhide API

    talklittle authored
This page is out of date. Refresh to see the latest.
Showing with 16 additions and 8 deletions.
  1. +16 −8 r2/r2/controllers/api.py
24 r2/r2/controllers/api.py
View
@@ -2158,9 +2158,9 @@ def POST_read_message(self, things):
@noresponse(VUser(),
VModhash(),
- thing = VByName('id', thing_cls=Link))
+ things = VByName('id', multiple=True, limit=25, thing_cls=Link))
@api_doc(api_section.links_and_comments)
- def POST_hide(self, thing):
+ def POST_hide(self, things):
"""Hide a link.
This removes it from the user's default view of subreddit listings.
@@ -2168,21 +2168,29 @@ def POST_hide(self, thing):
See also: [/api/unhide](#POST_api_unhide).
"""
- if not thing: return
- r = thing._hide(c.user)
+ if not things:
+ return
+ user = c.user
+ LinkHidesByAccount._hide(user, things)
+ for thing in things:
+ thing._something(SaveHide, user, thing._hidden, 'hide')
@noresponse(VUser(),
VModhash(),
- thing = VByName('id'))
+ things = VByName('id', multiple=True, limit=25, thing_cls=Link))
@api_doc(api_section.links_and_comments)
- def POST_unhide(self, thing):
+ def POST_unhide(self, things):
"""Unhide a link.
See also: [/api/hide](#POST_api_hide).
"""
- if not thing: return
- r = thing._unhide(c.user)
+ if not things:
+ return
+ user = c.user
+ LinkHidesByAccount._unhide(user, things)
+ for thing in things:
+ thing._unsomething(user, thing._hidden, 'hide')
@validatedForm(VUser(),
Something went wrong with that request. Please try again.