def publish_status(self): if not self.user: return self.socket.publish( 'user_status', { 'id': self.user.id, 'rating': self.user.rating, 'is_online': self.user.is_online, 'wins': Game.count_wins(self.db, self.user) })
def _connection_data(self): data = {} if self.user: data.update({ 'user_id': self.user.id, 'user_display': self.user.display, 'rating': self.user.rating, 'wins': Game.count_wins(self.db, self.user), 'automatch': self.db.query(Automatch).filter_by(user=self.user).count() > 0, }) data.update(self._connection_data_rooms()) data.update(self._connection_data_games()) data.update(self._connection_data_direct_rooms()) data.update(self._connection_data_active_games()) data.update(self._connection_data_challenges()) return data