Add get_live_subreddits method for LiveAdWeights.

This commit is contained in:
bsimpson63
2013-05-02 15:20:33 -04:00
parent fa69542e70
commit 356b6fa3ed

View File

@@ -199,6 +199,19 @@ class LiveAdWeights(object):
results[''] = results.pop(cls.FRONT_PAGE)
return results
@classmethod
def get_live_subreddits(cls):
q = cls._cf.get_range()
results = []
empty = {cls.column: '[]'}
for sr_id, columns in q:
if sr_id in (cls.ALL_ADS, cls.FRONT_PAGE):
continue
if not columns or columns == empty:
continue
results.append(int(sr_id))
return results
@classmethod
def set_all_from_weights(cls, all_weights):
"""Given a dictionary with all ads that should currently be running