Correct duplicate PromotionLog from mis-merge

This commit is contained in:
Keith Mitchell
2012-11-12 15:47:57 -08:00
parent 141f3d3b0a
commit 0aaf9b9307

View File

@@ -935,42 +935,6 @@ def get_total_run(link):
return earliest, latest
class PromotionLog(tdb_cassandra.View):
_use_db = True
_connection_pool = 'main'
_compare_with = TIME_UUID_TYPE
@classmethod
def _rowkey(cls, link):
return link._fullname
@classmethod
def add(cls, link, text):
name = c.user.name if c.user_is_loggedin else "<AUTOMATED>"
now = datetime.now(g.tz).strftime("%Y-%m-%d %H:%M:%S")
text = "[%s: %s] %s" % (name, now, text)
rowkey = cls._rowkey(link)
column = {uuid1(): filters._force_utf8(text)}
cls._set_values(rowkey, column)
# Dual write to old promotion_log attribute
log = list(getattr(link, "promotion_log", []))
log.append(text)
link.promotion_log = map(filters._force_utf8, log)
link._commit()
return text
@classmethod
def get(cls, link):
rowkey = cls._rowkey(link)
try:
row = cls._byID(rowkey)
except tdb_cassandra.NotFound:
return []
tuples = sorted(row._values().items(), key=lambda t: t[0].time)
return [t[1] for t in tuples]
def Run(offset=0, verbose=True):
"""reddit-job-update_promos: Intended to be run hourly to pull in
scheduled changes to ads