def update(cls, date, domain, new, old=None):
"""
Updates a timeline record for a given day. It also attempts
to update the data (if any) in memcached to prevent a full cache
reload.
"""
record = cls.query(cls.date == date).get()
if not record:
print 'no record found.'
record = StatusTimeline(domain=domain, date=date, statuses={})
record.put()
if old:
print 'Removing 1 from {}'.format(old)
record.statuses[old] -= 1
print 'Updating entry on {} to {} with new value {}'.format(
date, new, record.statuses[new])
record.statuses[new] += 1
record.put()
# Temporary update to memcached since the data is eventually
# consistent
cls._update_memcached(domain, time=5)
评论列表
文章目录