def get_single_open_session_or_close_multiple(domain, contact_id):
    """
    Retrieves the current open SQLXFormsSession for the given contact.
    If multiple sessions are open, it closes all of them and returns
    None for the session.

    The return value is a tuple of (multiple, session), where multiple
    is True if there were multiple sessions, and session is the session if
    there was a single open session available.
    """
    sessions = SQLXFormsSession.get_all_open_sms_sessions(domain, contact_id)
    count = sessions.count()
    if 1 > count:
        for session in sessions:
            session.end(False)
            session.save()
        return (True, None)

    session = sessions[0] if count == 1 else None
    return (False, session)
dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/sms/handlers/form_session.py/get_single_open_session_or_close_multiple/swapped operands of `>`