def refresh_sound_extra_data(): logger.info('Start refreshing freesound sound extra data') sound_ids = Sound.objects.all().values_list('freesound_id', flat=True) results = query_freesound_by_id(sound_ids, fields="id,name,analysis,images", descriptors="lowlevel.average_loudness") with transaction.atomic(): for freesound_sound in results: sound = Sound.objects.get(freesound_id=freesound_sound.id) sound.extra_data.update(freesound_sound.as_dict()) sound.save() logger.info('Finished refreshing freesound sound extra data')
def refresh_sound_deleted_state(): logger.info('Start refreshing freesound sound deleted state') sound_ids = Sound.objects.all().values_list('freesound_id', flat=True) results = query_freesound_by_id(sound_ids) deleted_sound_ids = set(sound_ids) - set([s.id for s in results]) with transaction.atomic(): for fs_sound_id in deleted_sound_ids: sound = Sound.objects.get(freesound_id=fs_sound_id) sound.deleted_in_freesound = True sound.save() logger.info('Finished refreshing freesound sound deleted state')