Removing the ten_reports method and passed the reports count through to the reports_node page

This commit is contained in:
stack72
2014-05-16 17:00:35 -05:00
parent 81c71607ae
commit 85dd8da276
3 changed files with 6 additions and 16 deletions

View File

@@ -21,7 +21,7 @@ from pypuppetdb import connect
from puppetboard.forms import QueryForm from puppetboard.forms import QueryForm
from puppetboard.utils import ( from puppetboard.utils import (
get_or_abort, yield_or_stop, get_or_abort, yield_or_stop,
ten_reports, limit_reports, jsonprint limit_reports, jsonprint
) )
@@ -193,12 +193,13 @@ def reports():
def reports_node(node): def reports_node(node):
"""Fetches all reports for a node and processes them eventually rendering """Fetches all reports for a node and processes them eventually rendering
a table displaying those reports.""" a table displaying those reports."""
reports = ten_reports(yield_or_stop( reports = limit_reports(yield_or_stop(
puppetdb.reports('["=", "certname", "{0}"]'.format(node)))) puppetdb.reports('["=", "certname", "{0}"]'.format(node))), app.config['REPORTS_COUNT'])
return render_template( return render_template(
'reports_node.html', 'reports_node.html',
reports=reports, reports=reports,
nodename=node) nodename=node,
reports_count=app.config['REPORTS_COUNT'])
@app.route('/report/latest/<node_name>') @app.route('/report/latest/<node_name>')

View File

@@ -1,5 +1,5 @@
{% extends 'layout.html' %} {% extends 'layout.html' %}
{% import '_macros.html' as macros %} {% import '_macros.html' as macros %}
{% block content %} {% 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 %} {% endblock content %}

View File

@@ -28,17 +28,6 @@ def get_or_abort(func, *args, **kwargs):
abort(204) 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): def limit_reports(reports, limit):
"""Helper to yield a number of from the reports generator. """Helper to yield a number of from the reports generator.