zeeguu/core/model/user_exercise_session.py
def _find_most_recent_session(cls, user_id, db_session):
        """
            Queries and returns if there is an open exercise session for that user

            Parameters: 
            user_id = user identifier
            db_session = database session

            returns: the active exercise_session record for the specific user or None if none is found
        """
        query = cls.query
        query = query.filter(cls.user_id == user_id)
        query = query.filter(cls.is_active == True)
        try:
            return query.one()

        except sqlalchemy.orm.exc.MultipleResultsFound:
            # Close all open sessions except last one
            query.order_by(cls.last_action_time)
            open_sessions = query.with_for_update().all()
            for exercise_session in open_sessions[:-1]:
                exercise_session._close_exercise_session(db_session)

            return open_sessions[-1]

        except sqlalchemy.orm.exc.NoResultFound:
            return None

            Queries and returns if there is an open exercise session for that user

            Parameters: 
            user_id = user identifier
            db_session = database session

            returns: the active exercise_session record for the specific user or None if none is found
        
Queries and returns if there is an open exercise session for that user
Parameters:
user_id = user identifier
db_session = database session

the active exercise_session record for the specific user or None if none is found
Queries and returns if there is an open exercise session for that user Parameters : user_id = user identifier db_session = database session the active exercise_session record for the specific user or None if none is found
def _find_most_recent_session(cls, user_id, db_session):
        query = cls.query
        query = query.filter(cls.user_id == user_id)
        query = query.filter(cls.is_active == True)
        try:
            return query.one()
        except sqlalchemy.orm.exc.MultipleResultsFound:
            query.order_by(cls.last_action_time)
            open_sessions = query.with_for_update().all()
            for exercise_session in open_sessions[:-1]:
                exercise_session._close_exercise_session(db_session)
            return open_sessions[-1]
        except sqlalchemy.orm.exc.NoResultFound:
            return None
def _find_most_recent_session ( cls , user_id , db_session ) : query = cls . query query = query . filter ( cls . user_id == user_id ) query = query . filter ( cls . is_active == True ) try : return query . one ( ) except sqlalchemy . orm . exc . MultipleResultsFound : query . order_by ( cls . last_action_time ) open_sessions = query . with_for_update ( ) . all ( ) for exercise_session in open_sessions [ : - 1 ] : exercise_session . _close_exercise_session ( db_session ) return open_sessions [ - 1 ] except sqlalchemy . orm . exc . NoResultFound : return None
Queries and returns if there is an open exercise session for that user
Parameters:
user_id = user identifier
db_session = database session
Queries and returns if there is an open exercise session for that user Parameters : user_id = user identifier db_session = database session
"""
            Queries and returns if there is an open exercise session for that user

            Parameters: 
            user_id = user identifier
            db_session = database session

            returns: the active exercise_session record for the specific user or None if none is found
        """ # Close all open sessions except last one
cls
user_id
db_session