def cluster_egonet(currency, cluster):
    direction = request.args.get("direction")
    if not cluster:
        abort(404, "Cluster not provided")
    try:
        cluster = int(cluster)
        cluster = str(cluster)
    except Exception:
        abort(404, "Invalid cluster ID")
    if not direction:
        direction = ""
    limit = request.args.get("limit")
    if not limit:
        limit = 50
    else:
        try:
            limit = int(limit)
        except Exception:
            abort(404, "Invalid limit value")
    try:
        egoNet = gm.ClusterEgoNet(
            gd.query_cluster(currency, cluster),
            gd.query_cluster_tags(currency, cluster),
            gd.query_cluster_incoming_relations(currency, cluster, int(limit)),
            gd.query_cluster_outgoing_relations(currency, cluster, int(limit)))
        ret = egoNet.construct(cluster, direction)
    except Exception:
        ret = {}
    return jsonify(ret)
def cluster(currency, cluster):
    if not cluster:
        abort(404, "Cluster not provided")
    try:
        cluster = int(cluster)
    except Exception:
        abort(404, "Invalid cluster ID")
    cluster_obj = gd.query_cluster(currency, cluster)
    return jsonify(cluster_obj.__dict__) if cluster_obj else jsonify({})
Beispiel #3
0
 def get(self, currency, cluster):
     """
     Returns a JSON with the tags of the cluster
     """
     if not cluster:
         abort(404, "Cluster id not provided")
     cluster_obj = gd.query_cluster(currency, cluster)
     if not cluster_obj:
         abort(404, "Cluster not found")
     cluster_obj.tags = gd.query_cluster_tags(currency, cluster)
     return cluster_obj
Beispiel #4
0
 def get(self, currency, cluster):
     """
     Returns a JSON with the details of the cluster
     """
     if not cluster:
         abort(404, "Cluster not provided")
     try:
         cluster = int(cluster)
     except Exception:
         abort(404, "Invalid cluster ID")
     cluster_obj = gd.query_cluster(currency, cluster)
     if not cluster_obj:
         abort(404, "Cluster not found")
     return cluster_obj
def cluster_with_tags(currency, cluster):
    if not cluster:
        abort(404, "Cluster id not provided")
    cluster_obj = gd.query_cluster(currency, cluster)
    cluster_obj.tags = gd.query_cluster_tags(currency, cluster)
    return jsonify(cluster_obj.__dict__) if cluster_obj else jsonify({})