def test_filter_active_nodes(self): node1 = Node("node1") node1.mark_activity() db.session.add(node1) node2 = Node("node2") db.session.add(node2) nodes = filter_active_nodes().all() self.assertEqual([node1], nodes)
def proposals(): nodes = filter_active_nodes() node_key = request.args.get('node_key') if node_key: nodes = nodes.filter_by(node_key=node_key) service_proposals = [] for node in nodes: service_proposals += node.get_service_proposals() return jsonify({'proposals': service_proposals})
def get_available_nodes(limit=None): nodes = filter_active_nodes() if limit: nodes = nodes.limit(limit) nodes = nodes.all() for node in nodes: node.country_string = get_country_string( node.get_country_from_service_proposal()) node.sessions_count = get_sessions_count(node_key=node.node_key) node.uptime = 'N/A' return nodes
def get_available_nodes(limit=None): nodes = filter_active_nodes() if limit: nodes = nodes.limit(limit) nodes = nodes.all() for node in nodes: node.country_string = get_country_string( node.get_country_from_service_proposal()) node.sessions_count = get_sessions_count(node_key=node.node_key) delta = datetime.utcnow() - node.updated_at node.last_seen = humanize.naturaltime(delta.total_seconds()) return nodes
def get_active_nodes_count(): count = filter_active_nodes().count() return count