From 356b6fa3ed9d1702bb7e104ce032954780700375 Mon Sep 17 00:00:00 2001 From: bsimpson63 Date: Thu, 2 May 2013 15:20:33 -0400 Subject: [PATCH] Add get_live_subreddits method for LiveAdWeights. --- r2/r2/models/promo.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/r2/r2/models/promo.py b/r2/r2/models/promo.py index 4ece23f12..ee5e80da2 100644 --- a/r2/r2/models/promo.py +++ b/r2/r2/models/promo.py @@ -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