Skip to content

Commit

Permalink
Strip milliseconds from HTML output
Browse files Browse the repository at this point in the history
  • Loading branch information
rfinnie committed Dec 28, 2022
1 parent 23cb44a commit badf0ee
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
8 changes: 7 additions & 1 deletion dsari/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ def __init__(self, args):
loader=loader,
extensions=["jinja2.ext.autoescape"],
)
self.templates.globals["now"] = datetime.datetime.now()
self.templates.globals.update({
"now": datetime.datetime.now(),
"strip_ms": lambda x: str(x).split(".", 2)[0],
})

self.db = dsari.database.get_database(self.config)

Expand Down Expand Up @@ -214,6 +217,9 @@ def render_index(self):
"runs": sorted(self.runs, key=lambda run: run.stop_time, reverse=True)[
:25
],
"failed_runs": sorted([run for run in self.runs if run.exit_code > 0], key=lambda run: run.stop_time, reverse=True)[
:10
],
}
index_html_filename = os.path.join(base_dir, "index.html")
if self.config.report_html_gz:
Expand Down
29 changes: 23 additions & 6 deletions dsari/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,24 @@
<body>
<div class="container">
<h1>dsari</h1>
<h2>Runs</h2>
<h2>Failed Runs</h2>
<table class="table table-striped">
<tr>
<th>Stop time</th>
<th>Job name</th>
<th>Duration</th>
<th>Exit code</th>
</tr>
{% for run in failed_runs %}
<tr{% if run.exit_code != 0 %} class="danger"{% endif %}>
<td><a href="{{ run.job.name }}/{{ run.id }}/">{{ strip_ms(run.stop_time) }}</a></td>
<td>{{ run.job.name }}</td>
<td>{{ strip_ms(run.stop_time - run.start_time) }}</td>
<td>{{ run.exit_code }}</td>
</tr>
{% endfor %}
</table>
<h2>Latest Runs</h2>
<table class="table table-striped">
<tr>
<th>Stop time</th>
Expand All @@ -21,9 +38,9 @@ <h2>Runs</h2>
</tr>
{% for run in runs %}
<tr{% if run.exit_code != 0 %} class="danger"{% endif %}>
<td><a href="{{ run.job.name }}/{{ run.id }}/">{{ run.stop_time }}</a></td>
<td><a href="{{ run.job.name }}/{{ run.id }}/">{{ strip_ms(run.stop_time) }}</a></td>
<td>{{ run.job.name }}</td>
<td>{{ run.stop_time - run.start_time }}</td>
<td>{{ strip_ms(run.stop_time - run.start_time) }}</td>
<td>{{ run.exit_code }}</td>
</tr>
{% endfor %}
Expand All @@ -39,9 +56,9 @@ <h2>Jobs</h2>
{% for job in jobs %}
<tr{% if job.last_run.start_time != job.last_successful_run.start_time %} class="danger"{% endif %}>
<td><a href="{{ job.name }}/">{{ job.name }}</a></td>
<td>{{ job.last_run.start_time }}</td>
<td>{% if job.last_run.start_time %}{{ job.last_run.stop_time - job.last_run.start_time }}{% endif %}</td>
<td>{{ job.last_successful_run.start_time }}</td>
<td>{{ strip_ms(job.last_run.start_time) }}</td>
<td>{% if job.last_run.start_time %}{{ strip_ms(job.last_run.stop_time - job.last_run.start_time) }}{% endif %}</td>
<td>{{ strip_ms(job.last_successful_run.start_time) }}</td>
</tr>
{% endfor %}
</table>
Expand Down

0 comments on commit badf0ee

Please sign in to comment.