Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sql.html 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. {% load i18n l10n %}{% load static %}
  2. <div class="djdt-clearfix">
  3. <ul class="djdt-stats">
  4. {% for alias, info in databases %}
  5. <li>
  6. <strong class="djdt-label"><span data-background-color="rgb({{ info.rgb_color|join:", " }})" class="djdt-color">&#160;</span> {{ alias }}</strong>
  7. <span class="djdt-info">{{ info.time_spent|floatformat:"2" }} ms ({% blocktrans count info.num_queries as num %}{{ num }} query{% plural %}{{ num }} queries{% endblocktrans %}
  8. {% if info.similar_count %}
  9. {% blocktrans with count=info.similar_count trimmed %}
  10. including <abbr title="Similar queries are queries with the same SQL, but potentially different parameters.">{{ count }} similar</abbr>
  11. {% endblocktrans %}
  12. {% if info.duplicate_count %}
  13. {% blocktrans with dupes=info.duplicate_count trimmed %}
  14. and <abbr title="Duplicate queries are identical to each other: they execute exactly the same SQL and parameters.">{{ dupes }} duplicates</abbr>
  15. {% endblocktrans %}
  16. {% endif %}
  17. {% endif %})</span>
  18. </li>
  19. {% endfor %}
  20. </ul>
  21. </div>
  22. {% if queries %}
  23. <table>
  24. <thead>
  25. <tr>
  26. <th class="djdt-color">&#160;</th>
  27. <th class="djdt-query" colspan="2">{% trans "Query" %}</th>
  28. <th class="djdt-timeline">{% trans "Timeline" %}</th>
  29. <th class="djdt-time">{% trans "Time (ms)" %}</th>
  30. <th class="djdt-actions">{% trans "Action" %}</th>
  31. </tr>
  32. </thead>
  33. <tbody>
  34. {% for query in queries %}
  35. <tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}{% if query.is_slow %} djDebugRowWarning{% endif %}{% if query.starts_trans %} djDebugStartTransaction{% endif %}{% if query.ends_trans %} djDebugEndTransaction{% endif %}{% if query.in_trans %} djDebugInTransaction{% endif %}" id="sqlMain_{{ forloop.counter }}">
  36. <td class="djdt-color"><span data-background-color="rgb({{ query.rgb_color|join:", " }})">&#160;</span></td>
  37. <td class="djdt-toggle">
  38. <a class="djToggleSwitch" data-toggle-name="sqlMain" data-toggle-id="{{ forloop.counter }}" data-toggle-open="+" data-toggle-close="-" href="">+</a>
  39. </td>
  40. <td class="djdt-query">
  41. <div class="djDebugSqlWrap">
  42. <div class="djDebugSql">{{ query.sql|safe }}</div>
  43. </div>
  44. {% if query.similar_count %}
  45. <strong>
  46. <span data-background-color="{{ query.similar_color }}">&#160;</span>
  47. {% blocktrans with count=query.similar_count %}{{ count }} similar queries.{% endblocktrans %}
  48. </strong>
  49. {% endif %}
  50. {% if query.duplicate_count %}
  51. <strong>
  52. <span data-background-color="{{ query.duplicate_color }}">&#160;</span>
  53. {% blocktrans with dupes=query.duplicate_count %}Duplicated {{ dupes }} times.{% endblocktrans %}
  54. </strong>
  55. {% endif %}
  56. </td>
  57. <td class="djdt-timeline">
  58. <div class="djDebugTimeline"><div class="djDebugLineChart{% if query.is_slow %} djDebugLineChartWarning{% endif %}" data-left="{{ query.start_offset|unlocalize }}%"><strong data-width="{{ query.width_ratio_relative|unlocalize }}%" data-background-color="{{ query.trace_color }}">{{ query.width_ratio }}%</strong></div></div>
  59. </td>
  60. <td class="djdt-time">
  61. {{ query.duration|floatformat:"2" }}
  62. </td>
  63. <td class="djdt-actions">
  64. {% if query.params %}
  65. {% if query.is_select %}
  66. <form method="post">
  67. {{ query.form }}
  68. <button formaction="{% url 'djdt:sql_select' %}" class="remoteCall">Sel</button>
  69. <button formaction="{% url 'djdt:sql_explain' %}" class="remoteCall">Expl</button>
  70. {% if query.vendor == 'mysql' %}
  71. <button formaction="{% url 'djdt:sql_profile' %}" class="remoteCall">Prof</button>
  72. {% endif %}
  73. </form>
  74. {% endif %}
  75. {% endif %}
  76. </td>
  77. </tr>
  78. <tr class="djUnselected {% cycle 'djDebugOdd' 'djDebugEven' %}{% if query.is_slow %} djDebugRowWarning{% endif %} djToggleDetails_{{ forloop.counter }}" id="sqlDetails_{{ forloop.counter }}">
  79. <td colspan="2"></td>
  80. <td colspan="4">
  81. <div class="djSQLDetailsDiv">
  82. <p><strong>{% trans "Connection:" %}</strong> {{ query.alias }}</p>
  83. {% if query.iso_level %}
  84. <p><strong>{% trans "Isolation level:" %}</strong> {{ query.iso_level }}</p>
  85. {% endif %}
  86. {% if query.trans_status %}
  87. <p><strong>{% trans "Transaction status:" %}</strong> {{ query.trans_status }}</p>
  88. {% endif %}
  89. {% if query.stacktrace %}
  90. <pre class="djdt-stack">{{ query.stacktrace }}</pre>
  91. {% endif %}
  92. {% if query.template_info %}
  93. <table>
  94. {% for line in query.template_info.context %}
  95. <tr>
  96. <td>{{ line.num }}</td>
  97. <td><code {% if line.highlight %}class="djdt-highlighted"{% endif %}>{{ line.content }}</code></td>
  98. </tr>
  99. {% endfor %}
  100. </table>
  101. <p><strong>{{ query.template_info.name|default:_("(unknown)") }}</strong></p>
  102. {% endif %}
  103. </div>
  104. </td>
  105. </tr>
  106. {% endfor %}
  107. </tbody>
  108. </table>
  109. {% else %}
  110. <p>{% trans "No SQL queries were recorded during this request." %}</p>
  111. {% endif %}
  112. <script src="{% static 'debug_toolbar/js/toolbar.sql.js' %}"></script>