Skip to content
Permalink
Browse files
Added type filter to sankey
  • Loading branch information
michellebeard committed Aug 30, 2017
1 parent c764399 commit 114f3375a3a528110ba41bc3079913f117f7f1ce
Showing 2 changed files with 21 additions and 15 deletions.
@@ -36,21 +36,10 @@ def generate_graph(app,
size=20):
"""
Return all elements from an application, possible matching against
a specific event (e.g. click, mouseover, etc)
a specific event type (e.g. click, mouseover, etc)
"""
# @TODO ref_url filter

# Filtering
should_query = []
if (target_events):
for event in target_events:
res = {
"term": {
"type": event
}
}
should_query.append(res)

must_not_query = [
{
"term": {
@@ -69,10 +58,20 @@ def generate_graph(app,
"term": {
"logType": log_type
},

},
]

# Filtering
# should_query = []
if (target_events):
for event in target_events:
res = {
"term": {
"type": event
}
}
filter_query.append(res)

# Sort By Time
sort_query = [
{
@@ -144,7 +143,7 @@ def generate_graph(app,
"query": {
"bool": {
# "must": must_match,
"should": should_query,
# "should": should_query,
"filter": filter_query,
"must_not": must_not_query,
}
@@ -163,6 +162,7 @@ def generate_graph(app,
"aggregations": agg_query
}

# return query
# Process Aggregate Results
response = es.search(app, doc_type=app_type, body=query, size=0)

@@ -409,7 +409,7 @@ def generate_graph(app,

res['nodes'] = node_map
res['links'] = links

res['sessions'] = sessions
with open('sankey.json', 'w') as outfile:
json.dump(res, outfile, sort_keys=False, indent=4)

@@ -96,7 +96,13 @@ def sankey(app_id):
if 'size' in request.args:
size = request.args.get('size')

# target events
events = []
if 'event' in request.args:
events.append(request.args.get('event'))

return jsonify(GraphAnalytics.generate_graph(app_id,
target_events=events,
time_range=ts_range,
size=size))

0 comments on commit 114f337

Please sign in to comment.