def handle(self, *args, **options):
        sound_qs = Sound.objects.select_related("pack", "user", "license") \
                                .filter(is_index_dirty=True,
                                        moderation_state='OK',
                                        processing_state='OK')

        add_all_sounds_to_solr(sound_qs, mark_index_clean=True)
    def handle(self, *args, **options):
        sound_qs = Sound.objects.select_related("pack", "user", "license") \
                                .filter(is_index_dirty=True,
                                        moderation_state='OK',
                                        processing_state='OK')

        logger.info("Starting posting dirty sounds to solr. %i sounds to be added/updated to the solr index" % sound_qs.count())
        add_all_sounds_to_solr(sound_qs, mark_index_clean=True)
        logger.info("Finished posting dirty sounds to solr. %i sounds have been added/updated" % sound_qs.count())
Exemple #3
0
    def handle(self, *args, **options):
        # Get all sounds moderated and processed ok
        sound_qs = Sound.objects.select_related("pack", "user", "license") \
                                .filter(processing_state="OK", moderation_state="OK")
        add_all_sounds_to_solr(sound_qs, mark_index_clean=True)

        # Get all sounds that should not be in solr and remove them if they are
        sound_qs = Sound.objects.exclude(processing_state="OK", moderation_state="OK")
        for sound in sound_qs:
            delete_sound_from_solr(sound)  # Will only do something if sound in fact exists in solr
Exemple #4
0
    def handle(self, *args, **options):
        sound_qs = Sound.objects.select_related("pack", "user", "license") \
                                .filter(is_index_dirty=True,
                                        moderation_state='OK',
                                        processing_state='OK')

        logger.info(
            "Starting posting dirty sounds to solr. %i sounds to be added/updated to the solr index"
            % sound_qs.count())
        add_all_sounds_to_solr(sound_qs, mark_index_clean=True)
        logger.info(
            "Finished posting dirty sounds to solr. %i sounds have been added/updated"
            % sound_qs.count())
Exemple #5
0
    def handle(self, *args, **options):
        mark_index_clean = not options['no_index_clean']

        # Get all sounds moderated and processed ok
        sounds_to_index = Sound.objects.filter(processing_state="OK", moderation_state="OK")
        console_logger.info("Reindexing %d sounds to solr", sounds_to_index.count())

        add_all_sounds_to_solr(sounds_to_index, mark_index_clean=mark_index_clean)

        # Get all sounds that should not be in solr and remove them if they are
        sound_qs = Sound.objects.exclude(processing_state="OK", moderation_state="OK")
        for sound in sound_qs:
            delete_sound_from_solr(sound.id)  # Will only do something if sound in fact exists in solr
    def handle(self, *args, **options):

        # Index all those which are processed and moderated ok that has is_index_dirty
        sounds_to_index = Sound.objects.filter(processing_state="OK", moderation_state="OK", is_index_dirty=True)
        num_sounds = sounds_to_index.count()
        logger.info("Starting posting dirty sounds to solr. %i sounds to be added/updated to the solr index"
                    % num_sounds)

        num_correctly_indexed_sounds = add_all_sounds_to_solr(sounds_to_index, mark_index_clean=True)

        logger.info("Finished posting dirty sounds to solr. %i sounds have been added/updated"
                    % num_correctly_indexed_sounds)

        # Remove all those which are not processed or moderated ok and that are still in solr (should not happen)
        sounds_dirty_to_remove = \
            Sound.objects.filter(is_index_dirty=True).exclude(moderation_state='OK', processing_state='OK')
        n_deleted_sounds = 0
        for sound in sounds_dirty_to_remove:
            if check_if_sound_exists_in_solr(sound):
                # We need to know if the sound exists in solr so that besides deleting it (which could be accomplished
                # by simply using delete_sound_from_solr), we know whether we have to change is_index_dirty state. If
                # we do not change it, then we would try to delete the sound at every attempt.
                delete_sound_from_solr(sound.id)
                n_deleted_sounds += 1
                sound.is_index_dirty = False
                sound.save()
        logger.info("Deleted %i sounds from solr index." % n_deleted_sounds)
Exemple #7
0
    def handle(self, *args, **options):

        # Index all those which are processed and moderated ok that has is_index_dirty
        sounds_to_index = Sound.objects.filter(processing_state="OK",
                                               moderation_state="OK",
                                               is_index_dirty=True)
        num_sounds = sounds_to_index.count()
        logger.info(
            "Starting posting dirty sounds to solr. %i sounds to be added/updated to the solr index"
            % num_sounds)

        num_correctly_indexed_sounds = add_all_sounds_to_solr(
            sounds_to_index,
            mark_index_clean=True,
            delete_if_existing=options['delete-if-existing'])

        logger.info(
            "Finished posting dirty sounds to solr. %i sounds have been added/updated"
            % num_correctly_indexed_sounds)

        # Remove all those which are not processed or moderated ok and that are still in solr (should not happen)
        sounds_dirty_to_remove = \
            Sound.objects.filter(is_index_dirty=True).exclude(moderation_state='OK', processing_state='OK')
        n_deleted_sounds = 0
        for sound in sounds_dirty_to_remove:
            if check_if_sound_exists_in_solr(sound):
                # We need to know if the sound exists in solr so that besides deleting it (which could be accomplished
                # by simply using delete_sound_from_solr), we know whether we have to change is_index_dirty state. If
                # we do not change it, then we would try to delete the sound at every attempt.
                delete_sound_from_solr(sound.id)
                n_deleted_sounds += 1
                sound.is_index_dirty = False
                sound.save()
        logger.info("Deleted %i sounds from solr index." % n_deleted_sounds)
Exemple #8
0
    def handle(self, *args, **options):

        # Get all sounds moderated and processed ok and add them to solr (also delete them before re-indexing)
        sounds_to_index = Sound.objects.filter(processing_state="OK",
                                               moderation_state="OK")
        console_logger.info("Re-indexing %d sounds to solr",
                            sounds_to_index.count())
        add_all_sounds_to_solr(sounds_to_index,
                               mark_index_clean=True,
                               delete_if_existing=True)

        # Delete all sounds in solr which are not found in the Freesound DB
        solr_ids = get_all_sound_ids_from_solr()
        indexed_sound_ids = sounds_to_index.values_list('id', flat=True)
        sound_ids_to_delete = list(set(solr_ids).difference(indexed_sound_ids))
        console_logger.info("Deleting %d non-existing sounds form solr",
                            len(sound_ids_to_delete))
        delete_sounds_from_solr(sound_ids=sound_ids_to_delete)
 def handle(self, *args, **options):
     sound_qs = Sound.objects.select_related("pack", "user", "license").filter(
         processing_state="OK", moderation_state="OK"
     )
     add_all_sounds_to_solr(sound_qs)
Exemple #10
0
 def read(self, request):
     sound_qs = Sound.objects.select_related("pack", "user", "license") \
                             .filter(processing_state="OK", moderation_state="OK")
     add_all_sounds_to_solr(sound_qs)
     return rc.ALL_OK
Exemple #11
0
 def handle(self, *args, **options):
     sound_qs = Sound.objects.select_related("pack", "user", "license") \
                             .filter(processing_state="OK", moderation_state="OK")
     add_all_sounds_to_solr(sound_qs)