3
3
4
4
5
5
# load python 3, fallback to python 2 if it fails
6
+ import json
7
+
6
8
try :
7
9
from urllib .parse import unquote , unquote_plus , quote_plus
8
10
except ImportError :
21
23
from pypuppetdb .QueryBuilder import (ExtractOperator , AndOperator ,
22
24
EqualsOperator , FunctionOperator ,
23
25
NullOperator , OrOperator ,
24
- LessEqualOperator , RegexOperator )
26
+ LessEqualOperator , RegexOperator , GreaterEqualOperator )
25
27
26
28
from puppetboard .forms import ENABLED_QUERY_ENDPOINTS , QueryForm
27
29
from puppetboard .utils import (get_or_abort , yield_or_stop ,
@@ -470,6 +472,7 @@ def reports_ajax(env, node_name):
470
472
order_dir = request .args .get ('order[0][dir]' , 'desc' )
471
473
order_args = '[{"field": "%s", "order": "%s"}]' % (order_filter , order_dir )
472
474
status_args = request .args .get ('columns[1][search][value]' , '' ).split ('|' )
475
+ date_args = request .args .get ('columns[0][search][value]' , '' )
473
476
max_col = len (REPORTS_COLUMNS )
474
477
for i in range (len (REPORTS_COLUMNS )):
475
478
if request .args .get ("columns[%s][data]" % i , None ):
@@ -493,6 +496,20 @@ def reports_ajax(env, node_name):
493
496
"configuration_version" , r"%s" % search_arg ))
494
497
reports_query .add (search_query )
495
498
499
+ if date_args :
500
+ dates = json .loads (date_args )
501
+
502
+ if len (dates ) > 0 :
503
+ date_query = AndOperator ()
504
+
505
+ if 'min' in dates :
506
+ date_query .add (GreaterEqualOperator ('end_time' , dates ['min' ]))
507
+
508
+ if 'max' in dates :
509
+ date_query .add (LessEqualOperator ('end_time' , dates ['max' ]))
510
+
511
+ reports_query .add (date_query )
512
+
496
513
status_query = OrOperator ()
497
514
for status_arg in status_args :
498
515
if status_arg in ['failed' , 'changed' , 'unchanged' ]:
0 commit comments