def find_old_vidyo_rooms(max_room_event_age):
    """Finds all Vidyo rooms that are:
       - linked to no events
       - linked only to events whose start date precedes today - max_room_event_age days
    """
    recently_used = (db.session.query(VCRoom.id)
                     .filter(VCRoom.type == 'vidyo',
                             Event.end_dt > (now_utc() - timedelta(days=max_room_event_age)))
                     .join(VCRoom.events)
                     .join(VCRoomEventAssociation.event)
                     .group_by(VCRoom.id))

    # non-deleted rooms with no recent associations
    return VCRoom.find_all(VCRoom.status != VCRoomStatus.deleted, ~VCRoom.id.in_(recently_used))