(domain, *args)
return num_users if 'inactive' not in args else len(user_ids) - num_users
Returns the number of mobile users who have submitted a form or SMS in the
    last 30 days
Returns the number of mobile users who have submitted a form or SMS in the
    last 30 days
Returns the number of mobile users who have submitted a form or SMS in the last 30 days
def active_mobile_users(domain, *args):
    """
    Returns the number of mobile users who have submitted a form or SMS in the
    last 30 days
    """
    now = datetime.utcnow()
    then = (now - timedelta(days=30))

    user_ids = get_mobile_users(domain)

    form_users = set(
        FormES()
        .domain(domain)
        .user_aggregation()
        .submitted(gte=then)
        .user_id(user_ids)
        .size(0)
        .run()
        .aggregations.user.keys
    )

    sms_users = set(
        SMSES()
        .incoming_messages()
        .user_aggregation()
        .to_commcare_user()
        .domain(domain)
        .received(gte=then)
        .size(0)
        .run()
        .aggregations.user.keys
    )

    num_users = len(form_users | sms_users)
    return num_users if 'inactive' not in args else len(user_ids) - num_users
def active_mobile_users ( domain , * args ) : now = datetime . utcnow ( ) then = ( now - timedelta ( days = 30 ) ) user_ids = get_mobile_users ( domain ) form_users = set ( FormES ( ) . domain ( domain ) . user_aggregation ( ) . submitted ( gte = then ) . user_id ( user_ids ) . size ( 0 ) . run ( ) . aggregations . user . keys ) sms_users = set ( SMSES ( ) . incoming_messages ( ) . user_aggregation ( ) . to_commcare_user ( ) . domain ( domain ) . received ( gte = then ) . size ( 0 ) . run ( ) . aggregations . user . keys ) num_users = len ( form_users | sms_users ) return num_users if 'inactive' not in args else len ( user_ids ) - num_users