Example #1
0
def get_indexed_cases(domain, case_ids):
    """
    Given a base list of cases, gets all wrapped cases that they reference
    (parent cases).
    """
    from casexml.apps.case.models import CommCareCase
    return [CommCareCase.wrap(doc) for doc in iter_docs(CommCareCase.get_db(),
                                                        get_indexed_case_ids(domain, case_ids))]
Example #2
0
def get_indexed_cases(domain, case_ids):
    """
    Given a base list of cases, gets all wrapped cases that they reference
    (parent cases).
    """
    from casexml.apps.case.models import CommCareCase
    return [CommCareCase.wrap(doc) for doc in iter_docs(CommCareCase.get_db(),
                                                        get_indexed_case_ids(domain, case_ids))]
Example #3
0
def get_case_footprint_info(domain, owner_id):
    """
    This function is duplicating a lot of functionality in get_footprint/get_related_cases.

    However it is unique in that it:
      1) starts from an owner_id instead of a base set of cases
      2) doesn't return full blown case objects but just IDs
      3) differentiates between the base set and the complete list
    """
    all_case_ids = set()
    # get base set of cases (anything open with this owner id)
    open_case_ids = get_open_case_ids(domain, owner_id)
    new_case_ids = set(open_case_ids)
    while new_case_ids:
        all_case_ids = all_case_ids | new_case_ids
        referenced_case_ids = get_indexed_case_ids(domain, list(new_case_ids))
        new_case_ids = set(referenced_case_ids) - all_case_ids

    return FootprintInfo(base_ids=set(open_case_ids), all_ids=all_case_ids)
Example #4
0
def get_case_footprint_info(domain, owner_id):
    """
    This function is duplicating a lot of functionality in get_footprint/get_related_cases.

    However it is unique in that it:
      1) starts from an owner_id instead of a base set of cases
      2) doesn't return full blown case objects but just IDs
      3) differentiates between the base set and the complete list
    """
    all_case_ids = set()
    # get base set of cases (anything open with this owner id)
    open_case_ids = get_open_case_ids(domain, owner_id)
    new_case_ids = set(open_case_ids)
    while new_case_ids:
        all_case_ids = all_case_ids | new_case_ids
        referenced_case_ids = get_indexed_case_ids(domain, list(new_case_ids))
        new_case_ids = set(referenced_case_ids) - all_case_ids

    return FootprintInfo(base_ids=set(open_case_ids), all_ids=all_case_ids)
Example #5
0
 def get_indexed_case_ids(domain, case_ids):
     return get_indexed_case_ids(domain, case_ids)
Example #6
0
 def get_indexed_case_ids(domain, case_ids):
     return get_indexed_case_ids(domain, case_ids)