(domains)
:param domains: list of {'name': <name>, '_id': <id>} entries
:param domains: list of {'name': <name>, '_id': <id>} entries
: param domains : list of { name : <name > _id : <id > } entries
def update_calculated_properties_for_domains(domains):
    """
    :param domains: list of {'name': <name>, '_id': <id>} entries
    """
    # relying on caching for efficiency
    all_stats = all_domain_stats()

    active_users_by_domain = {}
    for domain in domains:
        domain_obj = Domain.get_by_name(domain['name'])
        if not domain_obj:
            send_to_elasticsearch("domains", domain, delete=True)
            continue
        try:
            props = calced_props(domain_obj, domain['_id'], all_stats)
            active_users_by_domain[domain['name']] = props['cp_n_active_cc_users']
            if props['cp_first_form'] is None:
                del props['cp_first_form']
            if props['cp_last_form'] is None:
                del props['cp_last_form']
            if props['cp_300th_form'] is None:
                del props['cp_300th_form']
            send_to_elasticsearch("domains", props, es_merge_update=True)
        except Exception as e:
            notify_exception(
                None, message='Domain {} failed on stats calculations with {}'.format(domain['name'], e)
            )

    datadog_report_user_stats('commcare.active_mobile_workers.count', active_users_by_domain)
def update_calculated_properties_for_domains ( domains ) : # relying on caching for efficiency all_stats = all_domain_stats ( ) active_users_by_domain = { } for domain in domains : domain_obj = Domain . get_by_name ( domain [ 'name' ] ) if not domain_obj : send_to_elasticsearch ( "domains" , domain , delete = True ) continue try : props = calced_props ( domain_obj , domain [ '_id' ] , all_stats ) active_users_by_domain [ domain [ 'name' ] ] = props [ 'cp_n_active_cc_users' ] if props [ 'cp_first_form' ] is None : del props [ 'cp_first_form' ] if props [ 'cp_last_form' ] is None : del props [ 'cp_last_form' ] if props [ 'cp_300th_form' ] is None : del props [ 'cp_300th_form' ] send_to_elasticsearch ( "domains" , props , es_merge_update = True ) except Exception as e : notify_exception ( None , message = 'Domain {} failed on stats calculations with {}' . format ( domain [ 'name' ] , e ) ) datadog_report_user_stats ( 'commcare.active_mobile_workers.count' , active_users_by_domain )