示例#1
0
    def form_valid(self):
        res = queue_prime_restore(
            self.domain,
            CommCareUser.ids_by_domain(self.domain),
            version=V2,
            cache_timeout_hours=24,
            overwrite_cache=True,
            check_cache_only=False
        )
        download = MultipleTaskDownload()
        download.set_task(res)
        download.save()

        return redirect('hq_soil_download', self.domain, download.download_id)
示例#2
0
    def form_valid(self):
        if self.form.cleaned_data['all_users']:
            user_ids = CommCareUser.ids_by_domain(self.domain)
        else:
            user_ids = self.form.user_ids

        res = queue_prime_restore(
            self.domain,
            user_ids,
            version=V2,
            cache_timeout_hours=24,
            overwrite_cache=self.form.cleaned_data['overwrite_cache'],
            check_cache_only=self.form.cleaned_data['check_cache_only']
        )
        download = MultipleTaskDownload()
        download.set_task(res)
        download.save()

        return redirect('hq_soil_download', self.domain, download.download_id)
示例#3
0
 def get(self, request, domain, *args, **kwargs):
     cache = get_redis_client()
     download_id = cache.get(CACHE_KEY.format(domain))
     download = MultipleTaskDownload.get(download_id)
     if download:
         return redirect('hq_soil_download', domain, download.download_id)
     else:
         return HttpResponse(
             "Task with id: {} not found. Maybe it failed, never started, or completed a long time ago"
             .format(download_id))
示例#4
0
    def form_valid(self):
        res = queue_prime_restore(self.domain,
                                  CommCareUser.ids_by_domain(self.domain),
                                  version=V2,
                                  cache_timeout_hours=24,
                                  overwrite_cache=True,
                                  check_cache_only=False)
        download = MultipleTaskDownload()
        download.set_task(res)
        download.save()

        return redirect('hq_soil_download', self.domain, download.download_id)
示例#5
0
    def form_valid(self):
        if self.form.cleaned_data['all_users']:
            user_ids = CommCareUser.ids_by_domain(self.domain)
        else:
            user_ids = self.form.user_ids

        res = queue_prime_restore(
            self.domain,
            user_ids,
            version=V2,
            cache_timeout_hours=24,
            overwrite_cache=self.form.cleaned_data['overwrite_cache'],
            check_cache_only=self.form.cleaned_data['check_cache_only'])
        download = MultipleTaskDownload()
        download.set_task(res)
        download.save()

        return redirect('hq_soil_download', self.domain, download.download_id)
示例#6
0
def enikshay_task(self):
    # runs adherence and voucher calculations for all domains that have
    # `toggles.UATBC_ADHERENCE_TASK` enabled

    domains = toggles.UATBC_ADHERENCE_TASK.get_enabled_domains()
    for domain in domains:
        if toggles.DATA_MIGRATION.enabled(domain):
            # Don't run this on the india cluster anymore
            continue

        try:
            task_group = EpisodeUpdater(domain).run()
        except Exception as e:
            logger.error("error calculating reconciliation task for domain {}: {}".format(domain, e))

        download = MultipleTaskDownload()
        download.set_task(task_group)
        download.save()
        cache.set(CACHE_KEY.format(domain), download.download_id)

        send_status_email(domain, task_group.get())