diff --git a/r2/r2/controllers/front.py b/r2/r2/controllers/front.py index 6a9849160..d997deda7 100755 --- a/r2/r2/controllers/front.py +++ b/r2/r2/controllers/front.py @@ -437,18 +437,9 @@ class FrontController(RedditController, OAuth2ResourceController): return self.abort404() def _make_moderationlog(self, srs, num, after, reverse, count, mod=None, action=None): - - if mod and action: - query = Subreddit.get_modactions(srs, mod=mod, action=None) - def keep_fn(ma): - return ma.action == action - else: - query = Subreddit.get_modactions(srs, mod=mod, action=action) - def keep_fn(ma): - return True - - builder = QueryBuilder(query, skip=True, num=num, after=after, - keep_fn=keep_fn, count=count, + query = Subreddit.get_modactions(srs, mod=mod, action=action) + builder = QueryBuilder(query, num=num, after=after, + count=count, reverse=reverse, wrap=default_thing_wrapper()) listing = ModActionListing(builder) diff --git a/r2/r2/models/modaction.py b/r2/r2/models/modaction.py index 9491bedcb..c7b8b2700 100644 --- a/r2/r2/models/modaction.py +++ b/r2/r2/models/modaction.py @@ -257,17 +257,17 @@ class ModAction(tdb_cassandra.UuidThing, Printable): if not mod and not action: rowkeys = [sr._id36 for sr in srs] q = ModActionBySR.query(rowkeys, after=after, reverse=reverse, count=count) - elif mod and not action: + elif mod: mods = tup(mod) + key = '%s_%s' if not action else '%%s_%%s_%s' % action rowkeys = itertools.product([sr._id36 for sr in srs], [mod._id36 for mod in mods]) - rowkeys = ['%s_%s' % (sr, mod) for sr, mod in rowkeys] - q = ModActionBySRMod.query(rowkeys, after=after, reverse=reverse, count=count) - elif not mod and action: + rowkeys = [key % (sr, mod) for sr, mod in rowkeys] + view = ModActionBySRActionMod if action else ModActionBySRMod + q = view.query(rowkeys, after=after, reverse=reverse, count=count) + else: rowkeys = ['%s_%s' % (sr._id36, action) for sr in srs] q = ModActionBySRAction.query(rowkeys, after=after, reverse=reverse, count=count) - else: - raise NotImplementedError("Can't query by both mod and action") return q