You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kibble.apache.org by hu...@apache.org on 2018/09/12 12:28:03 UTC
[kibble] 05/06: add path filter to API end points that make sense
This is an automated email from the ASF dual-hosted git repository.
humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kibble.git
commit 2da57de670f69fd3bca7d427f63bdb76948bd91d
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Wed Sep 12 14:26:54 2018 +0200
add path filter to API end points that make sense
---
api/pages/code/changes.py | 10 ++++++++++
api/pages/code/commits.py | 10 ++++++++++
api/pages/code/committers.py | 10 ++++++++++
api/pages/code/top-commits.py | 10 ++++++++++
api/pages/code/trends.py | 20 ++++++++++++++++++++
5 files changed, 60 insertions(+)
diff --git a/api/pages/code/changes.py b/api/pages/code/changes.py
index 313db8c..c6233d4 100644
--- a/api/pages/code/changes.py
+++ b/api/pages/code/changes.py
@@ -131,6 +131,16 @@ def run(API, environ, indata, session):
query['query']['bool']['should'] = [{'term': {'committer_email': indata.get('email')}}, {'term': {'author_email': indata.get('email')}}]
query['query']['bool']['minimum_should_match'] = 1
+ # Path filter?
+ if indata.get('pathfilter'):
+ pf = indata.get('pathfilter')
+ if '!' in pf:
+ pf = pf.replace('!', '')
+ query['query']['bool']['must_not'] = query['query']['bool'].get('must_not', [])
+ query['query']['bool']['must_not'].append({'regexp': {'files_changed': pf}})
+ else:
+ query['query']['bool']['must'].append({'regexp': {'files_changed': pf}})
+
# Get timeseries for this period
query['aggs'] = {
'per_interval': {
diff --git a/api/pages/code/commits.py b/api/pages/code/commits.py
index a2fece3..2899f75 100644
--- a/api/pages/code/commits.py
+++ b/api/pages/code/commits.py
@@ -132,6 +132,16 @@ def run(API, environ, indata, session):
query['query']['bool']['should'] = [{'term': {'committer_email': indata.get('email')}}, {'term': {'author_email': indata.get('email')}}]
query['query']['bool']['minimum_should_match'] = 1
+ # Path filter?
+ if indata.get('pathfilter'):
+ pf = indata.get('pathfilter')
+ if '!' in pf:
+ pf = pf.replace('!', '')
+ query['query']['bool']['must_not'] = query['query']['bool'].get('must_not', [])
+ query['query']['bool']['must_not'].append({'regexp': {'files_changed': pf}})
+ else:
+ query['query']['bool']['must'].append({'regexp': {'files_changed': pf}})
+
# Get number of committers, this period
query['aggs'] = {
'commits': {
diff --git a/api/pages/code/committers.py b/api/pages/code/committers.py
index 133a458..7b6d518 100644
--- a/api/pages/code/committers.py
+++ b/api/pages/code/committers.py
@@ -132,6 +132,16 @@ def run(API, environ, indata, session):
query['query']['bool']['should'] = [{'term': {'committer_email': indata.get('email')}}, {'term': {'author_email': indata.get('email')}}]
query['query']['bool']['minimum_should_match'] = 1
+ # Path filter?
+ if indata.get('pathfilter'):
+ pf = indata.get('pathfilter')
+ if '!' in pf:
+ pf = pf.replace('!', '')
+ query['query']['bool']['must_not'] = query['query']['bool'].get('must_not', [])
+ query['query']['bool']['must_not'].append({'regexp': {'files_changed': pf}})
+ else:
+ query['query']['bool']['must'].append({'regexp': {'files_changed': pf}})
+
# Get top 25 committers this period
query['aggs'] = {
'committers': {
diff --git a/api/pages/code/top-commits.py b/api/pages/code/top-commits.py
index 5e3c52a..ce75268 100644
--- a/api/pages/code/top-commits.py
+++ b/api/pages/code/top-commits.py
@@ -123,6 +123,16 @@ def run(API, environ, indata, session):
query['query']['bool']['should'] = [{'term': {'committer_email': indata.get('email')}}, {'term': {'author_email': indata.get('email')}}]
query['query']['bool']['minimum_should_match'] = 1
+ # Path filter?
+ if indata.get('pathfilter'):
+ pf = indata.get('pathfilter')
+ if '!' in pf:
+ pf = pf.replace('!', '')
+ query['query']['bool']['must_not'] = query['query']['bool'].get('must_not', [])
+ query['query']['bool']['must_not'].append({'regexp': {'files_changed': pf}})
+ else:
+ query['query']['bool']['must'].append({'regexp': {'files_changed': pf}})
+
# Get top 25 committers this period
query['aggs'] = {
diff --git a/api/pages/code/trends.py b/api/pages/code/trends.py
index dba483e..69d9b13 100644
--- a/api/pages/code/trends.py
+++ b/api/pages/code/trends.py
@@ -129,6 +129,16 @@ def run(API, environ, indata, session):
if indata.get('email'):
query['query']['bool']['should'] = [{'term': {'committer_email': indata.get('email')}}, {'term': {'author_email': indata.get('email')}}]
query['query']['bool']['minimum_should_match'] = 1
+
+ # Path filter?
+ if indata.get('pathfilter'):
+ pf = indata.get('pathfilter')
+ if '!' in pf:
+ pf = pf.replace('!', '')
+ query['query']['bool']['must_not'] = query['query']['bool'].get('must_not', [])
+ query['query']['bool']['must_not'].append({'regexp': {'files_changed': pf}})
+ else:
+ query['query']['bool']['must'].append({'regexp': {'files_changed': pf}})
# Get number of commits, this period
res = session.DB.ES.count(
@@ -226,6 +236,16 @@ def run(API, environ, indata, session):
query['query']['bool']['must'].append({'term': {'sourceID': indata.get('source')}})
elif viewList:
query['query']['bool']['must'].append({'terms': {'sourceID': viewList}})
+
+ # Path filter?
+ if indata.get('pathfilter'):
+ pf = indata.get('pathfilter')
+ if '!' in pf:
+ pf = pf.replace('!', '')
+ query['query']['bool']['must_not'] = query['query']['bool'].get('must_not', [])
+ query['query']['bool']['must_not'].append({'regexp': {'files_changed': pf}})
+ else:
+ query['query']['bool']['must'].append({'regexp': {'files_changed': pf}})
# Get number of commits, this period