mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-02-01 10:14:57 -05:00
ModAction: Read from ModActionBySRActionMod.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user