Skip to content

Commit

Permalink
post_dirty_sounds_to_solr now properly logs correctly indexed sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
ffont committed Jul 30, 2015
1 parent 73ed06d commit 6297a17
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions sounds/management/commands/post_dirty_sounds_to_solr.py
Expand Up @@ -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)
4 changes: 3 additions & 1 deletion utils/search/search_general.py
Expand Up @@ -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:
Expand All @@ -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.")
Expand Down

0 comments on commit 6297a17

Please sign in to comment.