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 ,
27
+ GreaterEqualOperator )
25
28
26
29
from puppetboard .forms import ENABLED_QUERY_ENDPOINTS , QueryForm
27
30
from puppetboard .utils import (get_or_abort , yield_or_stop ,
@@ -470,6 +473,7 @@ def reports_ajax(env, node_name):
470
473
order_dir = request .args .get ('order[0][dir]' , 'desc' )
471
474
order_args = '[{"field": "%s", "order": "%s"}]' % (order_filter , order_dir )
472
475
status_args = request .args .get ('columns[1][search][value]' , '' ).split ('|' )
476
+ date_args = request .args .get ('columns[0][search][value]' , '' )
473
477
max_col = len (REPORTS_COLUMNS )
474
478
for i in range (len (REPORTS_COLUMNS )):
475
479
if request .args .get ("columns[%s][data]" % i , None ):
@@ -493,6 +497,20 @@ def reports_ajax(env, node_name):
493
497
"configuration_version" , r"%s" % search_arg ))
494
498
reports_query .add (search_query )
495
499
500
+ if date_args :
501
+ dates = json .loads (date_args )
502
+
503
+ if len (dates ) > 0 :
504
+ date_query = AndOperator ()
505
+
506
+ if 'min' in dates :
507
+ date_query .add (GreaterEqualOperator ('end_time' , dates ['min' ]))
508
+
509
+ if 'max' in dates :
510
+ date_query .add (LessEqualOperator ('end_time' , dates ['max' ]))
511
+
512
+ reports_query .add (date_query )
513
+
496
514
status_query = OrOperator ()
497
515
for status_arg in status_args :
498
516
if status_arg in ['failed' , 'changed' , 'unchanged' ]:
0 commit comments