def handle(self, *args, **options): indexupdates = set() unit_ids = set() source_unit_ids = set() # Grab all updates from the database for update in IndexUpdate.objects.iterator(): indexupdates.add(update.pk) unit_ids.add(update.unit_id) if update.source: source_unit_ids.add(update.unit_id) # Filter matching units units = Unit.objects.filter( id__in=unit_ids ) source_units = Unit.objects.filter( id__in=source_unit_ids ) # Udate index update_index(units, source_units) # Delete processed updates IndexUpdate.objects.filter(id__in=indexupdates).delete()
def handle(self, *args, **options): # Optionally rebuild indices from scratch if options['clean']: create_source_index() for lang in Language.objects.have_translation(): create_target_index(lang=lang.code) units = self.get_units(*args, **options) update_index(units)
def handle(self, *args, **options): # Grab all updates from the database updates = list(IndexUpdate.objects.all()) # Grab just IDs update_ids = [update.id for update in updates] source_update_ids = [update.id for update in updates if update.source] # Filter matching units units = Unit.objects.filter(indexupdate__id__in=update_ids) source_units = Unit.objects.filter( indexupdate__id__in=source_update_ids) # Udate index update_index(units, source_units) # Delete processed updates IndexUpdate.objects.filter(id__in=update_ids).delete()
def handle(self, *args, **options): # Grab all updates from the database updates = list(IndexUpdate.objects.all()) # Grab just IDs update_ids = [update.id for update in updates] source_update_ids = [update.id for update in updates if update.source] # Filter matching units units = Unit.objects.filter( indexupdate__id__in=update_ids ) source_units = Unit.objects.filter( indexupdate__id__in=source_update_ids ) # Udate index update_index(units, source_units) # Delete processed updates IndexUpdate.objects.filter(id__in=update_ids).delete()