From 85dd8da276883f4e59253cbff3b172acfeeab339 Mon Sep 17 00:00:00 2001 From: stack72 Date: Fri, 16 May 2014 17:00:35 -0500 Subject: [PATCH] Removing the ten_reports method and passed the reports count through to the reports_node page --- puppetboard/app.py | 9 +++++---- puppetboard/templates/reports_node.html | 2 +- puppetboard/utils.py | 11 ----------- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/puppetboard/app.py b/puppetboard/app.py index d613d14..463d0a4 100644 --- a/puppetboard/app.py +++ b/puppetboard/app.py @@ -21,7 +21,7 @@ from pypuppetdb import connect from puppetboard.forms import QueryForm from puppetboard.utils import ( get_or_abort, yield_or_stop, - ten_reports, limit_reports, jsonprint + limit_reports, jsonprint ) @@ -193,12 +193,13 @@ def reports(): def reports_node(node): """Fetches all reports for a node and processes them eventually rendering a table displaying those reports.""" - reports = ten_reports(yield_or_stop( - puppetdb.reports('["=", "certname", "{0}"]'.format(node)))) + reports = limit_reports(yield_or_stop( + puppetdb.reports('["=", "certname", "{0}"]'.format(node))), app.config['REPORTS_COUNT']) return render_template( 'reports_node.html', reports=reports, - nodename=node) + nodename=node, + reports_count=app.config['REPORTS_COUNT']) @app.route('/report/latest/') diff --git a/puppetboard/templates/reports_node.html b/puppetboard/templates/reports_node.html index 028911d..885b357 100644 --- a/puppetboard/templates/reports_node.html +++ b/puppetboard/templates/reports_node.html @@ -1,5 +1,5 @@ {% extends 'layout.html' %} {% import '_macros.html' as macros %} {% block content %} -{{ macros.reports_table(reports, nodename, condensed=False, hash_truncate=False, show_conf_col=True, show_agent_col=True, show_host_col=True)}} +{{ macros.reports_table(reports, nodename, reports_count, condensed=False, hash_truncate=False, show_conf_col=True, show_agent_col=True, show_host_col=True)}} {% endblock content %} diff --git a/puppetboard/utils.py b/puppetboard/utils.py index a4ad550..0699345 100644 --- a/puppetboard/utils.py +++ b/puppetboard/utils.py @@ -28,17 +28,6 @@ def get_or_abort(func, *args, **kwargs): abort(204) -def ten_reports(reports): - """Helper to yield the first then reports from the reports generator. - - This is an ugly solution at best... - """ - for count, report in enumerate(reports): - if count == 10: - raise StopIteration - yield report - - def limit_reports(reports, limit): """Helper to yield a number of from the reports generator.