mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-04-27 03:00:12 -04:00
Correct duplicate PromotionLog from mis-merge
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user