Last active
August 29, 2015 14:13
-
-
Save jdunne-kaplan/a1d98ddea7c35f1b6446 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import models | |
from lib.utils import AsyncBatchUpdateManager | |
from lib.utils import QueryBatchIterator | |
session = models.DBSession.get_by_key_name("18ceb0d6-52b7-4c67-b47c-ae72edfe4394") | |
print session.is_versioned | |
print "" | |
tles = models.TimelineEvent.query_unversioned(session) | |
mgr = AsyncBatchUpdateManager(batch_size=100) | |
updcount = 0 | |
delcount = 0 | |
def clean_action(tle): | |
global updcount, delcount | |
if tle.timeline_version is None: return | |
if tle.timeline_version == 1: | |
tle = tle.puttable() | |
tle.timeline_version = None | |
mgr.put(tle) | |
updcount += 1 | |
if tle.timeline_version > 1: | |
delcount += 1 | |
QueryBatchIterator.iterate(tles, 100, clean_action) | |
mgr.complete() | |
print updcount | |
print delcount | |
print "" | |
print mgr.has_errors() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment