def upload_oral_arguments_to_internet_archive(options): """Upload oral arguments to the Internet Archive""" q = options["queue"] af_pks = (Audio.objects.filter( Q(ia_upload_failure_count__lt=3) | Q(ia_upload_failure_count=None), filepath_ia="", ).exclude(local_path_mp3="").values_list("pk", flat=True).order_by()) count = len(af_pks) logger.info("Sending %s oral argument files to Internet Archive", count) throttle = CeleryThrottle(queue_name=q) for i, af_pk in enumerate(af_pks): throttle.maybe_wait() if i > 0 and i % 1000 == 0: logger.info("Sent %s/%s tasks to celery so far.", i, count) upload_audio_to_ia.si(af_pk).set(queue=q).apply_async()
def upload_oral_arguments_to_internet_archive(options): """Upload oral arguments to the Internet Archive""" q = options['queue'] af_pks = Audio.objects.filter(Q(ia_upload_failure_count__lt=3) | Q(ia_upload_failure_count=None), filepath_ia='')\ .exclude(local_path_mp3='')\ .values_list('pk', flat=True)\ .order_by() count = len(af_pks) logger.info("Sending %s oral argument files to Internet Archive", count) throttle = CeleryThrottle(queue_name=q) for i, af_pk in enumerate(af_pks): throttle.maybe_wait() if i > 0 and i % 1000 == 0: logger.info("Sent %s/%s tasks to celery so far.", i, count) upload_audio_to_ia.si(af_pk).set(queue=q).apply_async()