Removing the ten_reports method and passed the reports count through to the reports_node page
This commit is contained in:
@@ -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/<node_name>')
|
||||
|
||||
@@ -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 %}
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user