Commit 890c8fcc authored by delanoe's avatar delanoe

[Graph Explorer] More informations to the user.

parent f059770d
...@@ -58,7 +58,7 @@ def get_graph( request=None , corpus=None ...@@ -58,7 +58,7 @@ def get_graph( request=None , corpus=None
if mapList_size.count() < graph_constraints['mapList']: if mapList_size.count() < graph_constraints['mapList']:
# Do not compute the graph if mapList is not big enough # Do not compute the graph if mapList is not big enough
return {'nodes':[], 'links':[0,0,0]} return {'nodes':[mapList_size.count()], 'links':[0,0,0]}
# case of corpus not big enough # case of corpus not big enough
...@@ -119,7 +119,7 @@ def get_graph( request=None , corpus=None ...@@ -119,7 +119,7 @@ def get_graph( request=None , corpus=None
elif corpus_size_query.count() <= graph_constraints['corpusMin']: elif corpus_size_query.count() <= graph_constraints['corpusMin']:
# Do not compute the graph if corpus is not big enough # Do not compute the graph if corpus is not big enough
return {'nodes':[], 'links':[0,0]} return {'nodes':[corpus_size_query.count()], 'links':[0,0]}
else: else:
# If graph_constraints are ok then compute the graph in live # If graph_constraints are ok then compute the graph in live
......
...@@ -143,7 +143,9 @@ class Graph(APIView): ...@@ -143,7 +143,9 @@ class Graph(APIView):
# Test data length # Test data length
if len(data['nodes']) > 1 and len(data['links']) > 1 : # A graph needs more than 3 nodes and 3 links
# Others graphs are used to check the errors
if len(data['nodes']) > 3 and len(data['links']) > 3 :
# normal case -------------------------------- # normal case --------------------------------
if format_ == 'json': if format_ == 'json':
return JsonHttpResponse( return JsonHttpResponse(
...@@ -152,37 +154,52 @@ class Graph(APIView): ...@@ -152,37 +154,52 @@ class Graph(APIView):
) )
# -------------------------------------------- # --------------------------------------------
elif len(data['nodes']) == 0 and len(data['links']) == 2 : elif len(data['nodes']) == 1 and len(data['links']) == 2 :
# async data case # async data case
return JsonHttpResponse({ return JsonHttpResponse({
'msg': '''Your corpus is too small. 'msg': '''Problem: your corpus is too small (only %d documents).
Add more documents (more than %d documents)
Solution: Add more documents (more than %d documents)
in order to get a graph. in order to get a graph.
You can manage your corpus here: You can manage your corpus here:
http://%sgargantext.org/projects/%d/ http://%sgargantext.org/projects/%d/
''' % (graph_constraints['corpusMin'], "dev.", corpus.parent_id), ''' % ( data['nodes'][0]
, graph_constraints['corpusMin']
, "dev."
, corpus.parent_id
),
}, status=400) }, status=400)
elif len(data['nodes']) == 0 and len(data['links']) == 3 : elif len(data['nodes']) == 1 and len(data['links']) == 3 :
# async data case # async data case
return JsonHttpResponse({ return JsonHttpResponse({
'msg': '''Your map list is too small. 'msg': '''Problem: your map list is too small (currently %d terms).
Add some terms (more than %d terms)
Solution: Add some terms (more than %d terms)
in order to get a graph. in order to get a graph.
You can manage your map terms here: You can manage your map terms here:
http://%sgargantext.org/projects/%d/corpora/%d/terms http://%sgargantext.org/projects/%d/corpora/%d/terms
''' % (graph_constraints['mapList'], "dev.", corpus.parent_id, corpus.id), ''' % ( data['nodes'][0]
, graph_constraints['mapList']
, "dev."
, corpus.parent_id
, corpus.id
),
}, status=400) }, status=400)
elif len(data['nodes']) == 0 and len(data['links']) == 0 :
elif len(data['nodes']) == 0 and len(data['links']) == 1 :
# async data case # async data case
return JsonHttpResponse({ return JsonHttpResponse({
'msg': '''Async graph generation 'msg': '''Warning: Async graph generation.
Wait a while and discover your graph
Wait a while and discover your graph very soon.
Click on the link and see your current graph
processing on top of the list:
http://%sgargantext.org/projects/%d/corpora/%d/myGraph http://%sgargantext.org/projects/%d/corpora/%d/myGraph
''' % ("dev.", corpus.parent_id, corpus.id), ''' % ("dev.", corpus.parent_id, corpus.id),
}, status=400) }, status=400)
......
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