From 6297a17ada0ad644b3717a7816943250cc23d4d9 Mon Sep 17 00:00:00 2001 From: ffont Date: Thu, 30 Jul 2015 10:51:05 +0200 Subject: [PATCH] post_dirty_sounds_to_solr now properly logs correctly indexed sounds --- sounds/management/commands/post_dirty_sounds_to_solr.py | 4 ++-- utils/search/search_general.py | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/sounds/management/commands/post_dirty_sounds_to_solr.py b/sounds/management/commands/post_dirty_sounds_to_solr.py index f3eb186ca..8bdceb0db 100644 --- a/sounds/management/commands/post_dirty_sounds_to_solr.py +++ b/sounds/management/commands/post_dirty_sounds_to_solr.py @@ -35,5 +35,5 @@ def handle(self, *args, **options): 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()) + num_correctly_indexed_sounds = 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" % num_correctly_indexed_sounds) diff --git a/utils/search/search_general.py b/utils/search/search_general.py index 6ff2942a9..908b6485a 100644 --- a/utils/search/search_general.py +++ b/utils/search/search_general.py @@ -110,6 +110,7 @@ def add_all_sounds_to_solr(sound_queryset, slice_size=4000, mark_index_clean=Fal # Pass in a queryset to avoid needing a reference to # the Sound class, it causes circular imports. num_sounds = sound_queryset.count() + num_correctly_indexed_sounds = 0 for i in range(0, num_sounds, slice_size): print "Adding %i sounds to solr, slice %i"%(slice_size,i) try: @@ -118,9 +119,10 @@ def add_all_sounds_to_solr(sound_queryset, slice_size=4000, mark_index_clean=Fal if mark_index_clean: logger.info("Marking sounds as clean.") sounds.models.Sound.objects.filter(pk__in=[snd.id for snd in sounds_to_update]).update(is_index_dirty=False) + num_correctly_indexed_sounds += len(sounds_to_update) except SolrException, e: logger.error("failed to add sound batch to solr index, reason: %s" % str(e)) - + return num_correctly_indexed_sounds def get_all_sound_ids_from_solr(limit=False): logger.info("getting all sound ids from solr.")