Add option to elastic-recheck-graph to pick a single queue

In preperation for providing a web page that will just show hits on the
gate queue, add a '-q queue' option to elastic-recheck-graph.

Change-Id: I9217a2ceedf86ffe04851084df78238384fccd51
This commit is contained in:
Joe Gordon 2014-01-30 13:16:54 -08:00
parent 611fb9daaa
commit c9602ca826
3 changed files with 20 additions and 3 deletions

View File

@ -49,6 +49,8 @@ def main():
help='path to query file')
parser.add_argument('-o', dest='output',
help='output filename')
parser.add_argument('-q', dest='queue',
help='limit results to a specific query')
args = parser.parse_args()
classifier = er.Classifier(args.queries)
@ -63,6 +65,9 @@ def main():
start = now - (14 * 24 * STEP)
for query in classifier.queries:
if args.queue:
query['query'] = query['query'] + ('AND build_queue:"%s"' %
args.queue)
urlq = dict(search=query['query'],
fields=[],
offset=0,
@ -78,7 +83,9 @@ def main():
fails24=0,
data=[])
buglist.append(bug)
results = classifier.hits_by_query(query['query'], size=3000)
results = classifier.hits_by_query(query['query'],
args.queue,
size=3000)
facets_for_fail = er_results.FacetSet()
facets_for_fail.detect_facets(results,

View File

@ -286,8 +286,11 @@ class Classifier():
self.queries_dir = queries_dir
self.queries = loader.load(self.queries_dir)
def hits_by_query(self, query, facet=None, size=100):
es_query = qb.generic(query, facet=facet)
def hits_by_query(self, query, queue=None, facet=None, size=100):
if queue:
es_query = qb.single_queue(query, queue, facet=facet)
else:
es_query = qb.generic(query, facet=facet)
return self.es.search(es_query, size=size)
def classify(self, change_number, patch_number, short_build_uuid,

View File

@ -59,6 +59,13 @@ def generic(raw_query, facet=None):
return query
def single_queue(query, queue, facet=None):
"""A query for a single queue."""
return generic('%s '
'AND build_queue:"%s" ' %
(query, queue), facet=facet)
def result_ready(review, patch, name, short_build_uuid):
"""A query to determine if we have a failure for a particular patch.