<commit_before>from receiver.signals import successful_form_received

def process_cases(sender, xform, **kwargs):
    """Creates or updates case objects which live outside of the form"""
    # recursive import fail
    from corehq.apps.case.xform import get_or_update_cases
    cases = get_or_update_cases(xform)
    # attach domain if it's there
    if hasattr(xform, "domain"):
        domain = xform.domain
        def attach_domain(case):
            case.domain = domain
            return case
        cases = [attach_domain(case) for case in cases.values()]
    map(lambda case: case.save(), cases.values())
    
successful_form_received.connect(process_cases)<commit_msg>take 2 on fixing case processing<commit_after>from receiver.signals import successful_form_received

def process_cases(sender, xform, **kwargs):
    """Creates or updates case objects which live outside of the form"""
    # recursive import fail
    from corehq.apps.case.xform import get_or_update_cases
    cases = get_or_update_cases(xform).values()
    # attach domain if it's there
    if hasattr(xform, "domain"):
        domain = xform.domain
        def attach_domain(case):
            case.domain = domain
            return case
        cases = [attach_domain(case) for case in cases]
    map(lambda case: case.save(), cases)
    
successful_form_received.connect(process_cases)
{'fraction_non_alphanumeric': 0.08552631578947369, 'fraction_numerical': 0.0007309941520467836, 'mean_word_length': 3.43042071197411, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7457545', 'n_tokens_mistral': 391, 'n_tokens_neox': 385, 'n_words': 114}