Skip to content

Instantly share code, notes, and snippets.

@jdunne-kaplan
Created March 12, 2015 14:22
Show Gist options
  • Save jdunne-kaplan/bc6a2ee667ec27209fb9 to your computer and use it in GitHub Desktop.
Save jdunne-kaplan/bc6a2ee667ec27209fb9 to your computer and use it in GitHub Desktop.
Rebuild TLE index for session
import models
from lib.utils import AsyncBatchUpdateManager
from lib.utils import QueryBatchIterator
session = models.DBSession.get_by_key_name("4c80b95e-5554-4dfb-8807-839d7851ab36")
print session.is_versioned
print ""
tles = models.TimelineEvent.query_unversioned(session)
mgr = AsyncBatchUpdateManager(batch_size=100)
updcount = 0
def clean_action(tle):
global updcount
tle = tle.puttable()
mgr.put(tle)
updcount += 1
QueryBatchIterator.iterate(tles, 100, clean_action)
mgr.complete()
print updcount
print ""
print mgr.has_errors()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment