Example #1
0
    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.all()[:options['limit']].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()
Example #2
0
    def do_update(self, limit):
        indexupdates = set()
        unit_ids = set()
        source_unit_ids = set()

        # Grab all updates from the database
        with transaction.atomic():
            updates = IndexUpdate.objects.filter(to_delete=False)
            for update in updates[:limit].iterator():
                indexupdates.add(update.pk)
                unit_ids.add(update.unitid)

                if update.source:
                    source_unit_ids.add(update.unitid)

        # 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
        with transaction.atomic():
            IndexUpdate.objects.filter(id__in=indexupdates).delete()
Example #3
0
    def do_update(self, limit):
        indexupdates = set()
        unit_ids = set()
        source_unit_ids = set()

        # Grab all updates from the database
        with transaction.atomic():
            updates = IndexUpdate.objects.filter(to_delete=False)
            for update in updates[:limit].iterator():
                indexupdates.add(update.pk)
                unit_ids.add(update.unitid)

                if update.source:
                    source_unit_ids.add(update.unitid)

        # 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
        with transaction.atomic():
            IndexUpdate.objects.filter(id__in=indexupdates).delete()
Example #4
0
    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)
Example #5
0
    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)
Example #6
0
    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.all()[:options['limit']].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()