Currently, the number of users online only decreases if users log out manually. Otherwise they stay "online" forever.
num_users_online = db.session.query(User.id).filter(User.authenticated).count()