Plain is headed towards 1.0! Subscribe for development updates →

 1<!DOCTYPE html>
 2<html lang="en">
 3<head>
 4    <meta charset="UTF-8">
 5    <meta name="viewport" content="width=device-width, initial-scale=1.0">
 6    <title>Document</title>
 7    {% tailwind_css %}
 8</head>
 9<body>
10
11    <div class="px-6 py-4">
12        <div class="flex items-center justify-between">
13            <h2 class="text-xl font-medium">Query stats for {{ request.path }}</h2>
14            <div class="flex items-center">
15                <div class="pt-1">
16                    {{ querystats.summary }}
17                </div>
18
19                <form action="." method="get">
20                    <input type="hidden" name="querystats" value="store">
21                    <button type="submit" class="flex items-center px-3 py-2 ml-4 text-sm rounded-full bg-zinc-600 hover:bg-zinc-500">
22                        <svg xmlns="http://www.w3.org/2000/svg" class="w-4 h-4 mr-2" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-refresh-cw"><polyline points="23 4 23 10 17 10"></polyline><polyline points="1 20 1 14 7 14"></polyline><path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"></path></svg>
23                        reload
24                    </button>
25                </form>
26            </div>
27        </div>
28        {#
29        <div class="mt-2 font-mono text-xs">
30            {{ querystats_resolver_match }}
31            and template {{ querystats_template_name }}
32        </div>
33        #}
34
35        <div class="flex w-full mt-5 overflow-auto rounded-sm">
36            {% for query in querystats.queries %}
37            <a href="#query-{{ loop.index }}"
38                {{ loop.cycle('class=\"h-4 bg-amber-400\"', 'class="h-4 bg-amber-500"', 'class="h-4 bg-amber-600"')|safe }}
39                title="[{{ query.duration_display }}] {{ query.sql_display }}"
40                style="width: {{ query.duration / querystats.total_time * 100 }}%">
41            </a>
42            {% endfor %}
43        </div>
44
45        <div class="mt-4 space-y-4 text-sm">
46            {% for query in querystats.queries %}
47            <div id="query-{{ loop.index }}" class="p-2 rounded bg-zinc-800">
48                <div class="float-right px-2 py-px mb-px ml-2 text-xs rounded-full bg-zinc-700">
49                    <span>{{ query.duration_display }}</span>
50                    {% if query.duplicate_count is defined %}
51                    <span class="text-red-500">&nbsp; duplicated {{ query.duplicate_count }} times</span>
52                    {% endif %}
53
54                    {#
55                    <div>many {{ query.many }}</div>
56                    <div>result {{ query.result }}</div>
57                    #}
58                </div>
59                <div>
60                    <pre><code class="font-mono whitespace-pre-wrap text-zinc-100">{{ query.sql_display }}</code></pre>
61                </div>
62                <div class="mt-3 text-zinc-400">
63                    <span class="font-medium">Parameters</span>
64                    <pre><code class="font-mono">{{ query.params|pprint }}</code></pre>
65                </div>
66                <details class="mt-3">
67                    <summary>Traceback</summary>
68                    <pre><code class="block overflow-x-auto font-mono text-xs">{{ query.tb }}</code></pre>
69                </details>
70            </div>
71            {% else %}
72            <div>No queries...</div>
73            {% endfor %}
74        </div>
75    </div>
76
77</body>
78</html>