Anton Shestakov <av6@dwimlabs.net>, Sun, 24 Sep 2017 12:25:05 +0800
viewer: use subqueries to get data on index page
Before, there were bare columns in the aggregate query, their values were
undefined (but it somehow worked), as SQLite docs say. Good news is that now
this bigger query uses (project_id, ordinal) index and is really fast.
templates/check.html
Permissions: -rw-r--r--
{% extends "base.html" %} {% block title %}Check #
{{ check.ordinal }}{% end %} <div class="uk-container uk-container-center uk-margin-large-top"> {% module Template('ui/project-link.html', project=project) %} <span class="uk-text-nowrap">· check #
{{ check.ordinal }}</span> <div class="uk-width-small-1-3"> <dl class="uk-description-list-horizontal list-terse"> <dd>{% module Time(check.started) %}</dd> <dd>{% module Time(check.finished) %}</dd> <dd>{{ check.get_duration() }}</dd> <img src="{{ project.get_url() }}/{{ check.ordinal }}/dot.svg" alt="Check Result"> {{ locale.translate('{} error', '{} errors', check.errors).format(check.errors) }},
{{ locale.translate('{} warning', '{} warnings', check.warnings).format(check.warnings) }} <dd><a href="{{ project.get_url() }}/{{ check.ordinal }}/raw">raw
</a></dd> <div class="uk-width-small-2-3"> <dl class="uk-description-list-horizontal list-terse"> {% set change = check.change %} <dd><a href="{{ adapter.get_commit_url(change) }}">{% if change.rev is not None %}{{ change.rev }}:
{% end %}{{ change.node[:12] }}</a></dd> <dd><a href="{{ adapter.get_branch_url(change) }}">{{ change.branch }}</a></dd> <dd>{{ change.author }}</dd> <dd>{% module Time(change.date, False) %}</dd> <dd>{{ change.message }}</dd> {% if reference is not None %} {% if check.errors > reference.errors %} <span class="uk-text-danger">worse
</span> than
{% elif check.errors < reference.errors %} <span class="uk-text-success">better
</span> than
{% if check.warnings > reference.warnings %} <span class="uk-text-warning">worse
</span> than
{% elif check.warnings < reference.warnings %} <span class="uk-text-success">better
</span> than
<a href="{{ project.get_url() }}/{{ reference.ordinal }}">check #
{{ reference.ordinal }}</a>,
the previous check on branch
{{ change.branch }} (
<a href="{{ project.get_url() }}/{{ check.ordinal }}/compare/{{ reference.ordinal }}">compare
</a>).
<div class="chart-container"><svg id="check-chart"></svg></div> <script type="application/json" id="check-chart-data">{% raw json_encode(chart) %}</script> {% include ui/check-log.html %}