Commit 60dfb9eb authored by Alexander Lercher's avatar Alexander Lercher

added rest get for user graphs

parent 933c956b
......@@ -129,7 +129,20 @@ paths:
# responses:
# 200:
# description: "Successful operation"
/user-cluster-graphs:
get:
operationId: "rest.user_cluster.get"
tags:
- "User Graphs"
summary: "Get user graphs per layer per cluster"
parameters: []
responses:
200:
description: "Successful operation"
schema:
$ref: "#/definitions/UserClusterGraphCollection"
definitions:
Location:
type: "object"
......@@ -163,8 +176,6 @@ definitions:
type: array
items:
$ref: "#/definitions/Location"
# example:
# 0: [1dc61b1a0602de0eaee9dba7eece9279c2844202, b4b31bbe5e12f55737e3a910827c81595fbca3eb]
LocationClusterCollection:
type: array
......@@ -186,10 +197,31 @@ definitions:
type: array
items:
$ref: "#/definitions/Location"
# example:
# 0: [1dc61b1a0602de0eaee9dba7eece9279c2844202, b4b31bbe5e12f55737e3a910827c81595fbca3eb]
TimeClusterCollection:
type: array
items:
$ref: "#/definitions/TimeCluster"
\ No newline at end of file
$ref: "#/definitions/TimeCluster"
UserClusterGraph:
type: object
properties:
nodes:
type: array
items:
type: string
edges:
type: array
items:
type: array
items:
type: string
example:
- user1
- user2
- weight
UserClusterGraphCollection:
type: array
items:
$ref: "#/definitions/UserClusterGraph"
\ No newline at end of file
......@@ -24,13 +24,13 @@ def get_edges_with_weights(g: Graph) -> List[Tuple[Any, Any, int]]:
return res
def create_graphs_for_clusters():
def create_graphs_for_location_clusters():
graphs_for_clusters = []
ug = UserGraphGenerator()
clusters: Cluster = repo.get_location_clusters()
for cluster in clusters[11:12]:
for cluster in clusters:
user_ids = [n['user'] for n in cluster.nodes]
graph: Graph = ug.create_graph_from_nodes(user_ids)
......@@ -49,4 +49,4 @@ def store_graphs(graphs: List):
if __name__ == "__main__":
create_graphs_for_clusters()
create_graphs_for_location_clusters()
from flask import request, Response
from db.repository import Repository
repo = Repository()
def get():
data = repo.get_user_cluster_graphs()
return [d.to_serializable_dict() for d in data]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment