def flag_forgotten_entries(session, today=None):
    """Flag any entries from previous days where users forgot to sign
    out.

    :param session: SQLAlchemy session through which to access the database.
    :param today: (optional) The current date as a `datetime.date` object. Used for testing.
    """ # noqa
    today = date.today() if today is None else today

    forgotten = (
        session
        .query(Entry)
        .filter(Entry.time_out.is_(None))
        .filter(Entry.forgot_sign_out.is_(False))
        .filter(Entry.date < today)
    )

    for entry in forgotten:
        e = sign_out(entry, forgot=True)
        logger.debug('Signing out forgotten entry: {}'.format(e))
        session.add(e)

    session.commit()
Flag any entries from previous days where users forgot to sign
    out.

    :param session: SQLAlchemy session through which to access the database.
    :param today: (optional) The current date as a `datetime.date` object. Used for testing.