headers = {'Private-Token': os.environ.get('GITLAB_TOKEN', '')}
-@app.route('/')
-def index():
+def parse_args():
args = {}
if request.args:
if 'status' in request.args:
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/<string:runner>')
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/")