def handle(self, *args, **options): t_total_start = time() self.connect(**options) self.log("You're running a script to import getpersonas.com to AMO!") self.log("Grab some coffee and settle in.") try: count = self.count_users() self.log('Going to import %s users.' % count) step = 30 for offset in range(0, count, step): t_start = time() self.do_import(offset, step) self.commit_or_not(options.get('commit')) t_average = 1 / ((time()- t_total_start) / (offset + step)) print "> %.2fs for %s accounts. Averaging %.2f accounts/s" % ( time() - t_start, step, t_average) except: self.log('Error, not committing changes.') transaction.rollback() raise finally: self.commit_or_not(options.get('commit')) if options.get('commit') == 'yes': self.log("Kicking off cron to reindex personas...") cron.reindex_addons(addon_type=amo.ADDON_PERSONA) self.log("Done. Total time: %s seconds" % (time() - t_total_start))
def test_job(self): cron.reindex_addons() self.refresh() eq_(sorted(a.id for a in Addon.search()), sorted(a.id for a in self.apps + self.addons))
def setUpClass(cls): super(TestAppSearch, cls).setUpClass() reindex_addons()
"""Reindex add-ons to fix stale data left by changes to the post_save handler.""" from addons.cron import reindex_addons reindex_addons()