Esempio n. 1
0
def handle_case_timed_schedule_instance(case_id, schedule_instance_id):
    # Use the same lock key as the tasks which refresh case schedule instances
    from corehq.messaging.tasks import get_sync_key
    with CriticalSection([get_sync_key(case_id)], timeout=5 * 60):
        try:
            instance = get_case_schedule_instance(CaseTimedScheduleInstance, case_id, schedule_instance_id)
        except CaseTimedScheduleInstance.DoesNotExist:
            return

        _handle_schedule_instance(instance, save_case_schedule_instance)
Esempio n. 2
0
def handle_case_timed_schedule_instance(case_id, schedule_instance_id):
    # Use the same lock key as the tasks which refresh case schedule instances
    from corehq.messaging.tasks import get_sync_key
    with CriticalSection([get_sync_key(case_id)], timeout=5 * 60):
        try:
            instance = get_case_schedule_instance(CaseTimedScheduleInstance,
                                                  case_id,
                                                  schedule_instance_id)
        except CaseTimedScheduleInstance.DoesNotExist:
            return

        _handle_schedule_instance(instance, save_case_schedule_instance)
Esempio n. 3
0
    def handle(self, **options):
        rule = self.get_rule(options['domain'], options['rule_id'])

        print("Fetching case ids...")
        case_ids = CaseAccessors(rule.domain).get_case_ids_in_domain(rule.case_type)
        case_id_chunks = list(chunked(case_ids, 10))

        for case_id_chunk in with_progress_bar(case_id_chunks):
            case_id_chunk = list(case_id_chunk)
            with CriticalSection([get_sync_key(case_id) for case_id in case_id_chunk], timeout=5 * 60):
                for case in CaseAccessors(rule.domain).get_cases(case_id_chunk):
                    rule.run_rule(case, utcnow())
Esempio n. 4
0
    def handle(self, **options):
        rule = self.get_rule(options['domain'], options['rule_id'])

        print("Fetching case ids...")
        case_ids = CaseAccessors(rule.domain).get_case_ids_in_domain(
            rule.case_type)
        case_id_chunks = list(chunked(case_ids, 10))

        for case_id_chunk in with_progress_bar(case_id_chunks):
            case_id_chunk = list(case_id_chunk)
            with CriticalSection(
                [get_sync_key(case_id) for case_id in case_id_chunk],
                    timeout=5 * 60):
                for case in CaseAccessors(
                        rule.domain).get_cases(case_id_chunk):
                    rule.run_rule(case, utcnow())