From 60410d604550f022ed13803b32eeeeb197e69829 Mon Sep 17 00:00:00 2001 From: Tom Powell Date: Tue, 30 Oct 2018 00:21:24 -0700 Subject: [PATCH] Order correctly, add filters to runners --- ui/app.py | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/ui/app.py b/ui/app.py index 44cca2c..1bfbdff 100644 --- a/ui/app.py +++ b/ui/app.py @@ -28,8 +28,7 @@ nav.register_element('top', Navbar( headers = {'Private-Token': os.environ.get('GITLAB_TOKEN', '')} -@app.route('/') -def index(): +def parse_args(): args = {} if request.args: if 'status' in request.args: @@ -41,18 +40,28 @@ def index(): if 'type' in request.args: args['build_type'] = request.args.get('type') if 'date' in request.args: - try: - date = datetime.datetime.strptime(request.args.get('date'), '%Y-%m-%d').date() - args['build_date'] = datetime.datetime.strptime(request.args.get('date'), '%Y-%m-%d').date() - except ValueError: - return "Invalid Date", 400 - builds = models.Build.query.filter_by(**args).paginate(per_page=20) + date = datetime.datetime.strptime(request.args.get('date'), '%Y-%m-%d').date() + args['build_date'] = datetime.datetime.strptime(request.args.get('date'), '%Y-%m-%d').date() + return args + +@app.route('/') +def index(): + try: + args = parse_args() + except ValueError: + return "Invalid Date", 400 + builds = models.Build.query.filter_by(**args).order_by(models.Build.build_date.desc(), models.Build.build_id).paginate(per_page=20) return render_template('builds.html', builds=builds) @app.route('/runners/') def runner(runner): + try: + args = parse_args() + except ValueError: + return "Invalid Date", 400 runner = models.Runner.query.filter_by(runner_name=runner).first() - builds = models.Build.query.filter_by(build_runner=runner).paginate(per_page=20) + args['build_runner'] = runner + builds = models.Build.query.filter_by(**args).order_by(models.Build.build_date.desc(), models.Build.build_id).paginate(per_page=20) return render_template('runner.html', runner=runner, builds=builds) @app.route("/runners/") -- 2.20.1