performance.views.inc 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <?php
  2. /**
  3. * @file
  4. * Views integration for the Performance module.
  5. */
  6. /**
  7. * Implements hook_views_data().
  8. */
  9. function performance_views_data() {
  10. // The 'group' index will be used as a prefix in the UI for any of this
  11. // table's fields, sort criteria, etc. so it's easy to tell where they came
  12. // from.
  13. // Find it a bit silly in the performance logging context but it's mandatory.
  14. $data['performance_detail']['table']['group'] = t('Performance logging details');
  15. $data['performance_detail']['table']['base'] = array(
  16. 'field' => 'pid',
  17. 'title' => t('Performance logging details'),
  18. 'weight' => -10,
  19. );
  20. // Path ID field.
  21. $data['performance_detail']['pid'] = array(
  22. 'title' => t('Path ID'),
  23. 'help' => t('Serialised ID field.'),
  24. 'field' => array(
  25. 'handler' => 'views_handler_field_numeric',
  26. 'click sortable' => TRUE,
  27. ),
  28. 'filter' => array(
  29. 'handler' => 'views_handler_filter_numeric',
  30. ),
  31. 'sort' => array(
  32. 'handler' => 'views_handler_sort',
  33. ),
  34. );
  35. // Last access field.
  36. $data['performance_detail']['timestamp'] = array(
  37. 'title' => t('Timestamp'),
  38. 'help' => t('Time when this data was recorded.'),
  39. 'field' => array(
  40. 'handler' => 'views_handler_field_date',
  41. 'click sortable' => TRUE,
  42. ),
  43. 'sort' => array(
  44. 'handler' => 'views_handler_sort_date',
  45. ),
  46. 'filter' => array(
  47. 'handler' => 'views_handler_filter_date',
  48. ),
  49. );
  50. // Bytes field.
  51. $data['performance_detail']['bytes'] = array(
  52. 'title' => t('Bytes'),
  53. 'help' => t('Amount of memory consumed in bytes when rendering the page.'),
  54. 'field' => array(
  55. 'handler' => 'views_handler_field_numeric',
  56. 'click sortable' => TRUE,
  57. ),
  58. 'filter' => array(
  59. 'handler' => 'views_handler_filter_numeric',
  60. ),
  61. 'sort' => array(
  62. 'handler' => 'views_handler_sort',
  63. ),
  64. );
  65. // Bytes field.
  66. $data['performance_detail']['ms'] = array(
  67. 'title' => t('Milliseconds'),
  68. 'help' => t('Amount of milliseconds needed to render this page.'),
  69. 'field' => array(
  70. 'handler' => 'views_handler_field_numeric',
  71. 'click sortable' => TRUE,
  72. ),
  73. 'filter' => array(
  74. 'handler' => 'views_handler_filter_numeric',
  75. ),
  76. 'sort' => array(
  77. 'handler' => 'views_handler_sort',
  78. ),
  79. );
  80. // Query count field.
  81. $data['performance_detail']['query_count'] = array(
  82. 'title' => t('Query count'),
  83. 'help' => t('Amount of queries executed when rendering this page.'),
  84. 'field' => array(
  85. 'handler' => 'views_handler_field_numeric',
  86. 'click sortable' => TRUE,
  87. ),
  88. 'filter' => array(
  89. 'handler' => 'views_handler_filter_numeric',
  90. ),
  91. 'sort' => array(
  92. 'handler' => 'views_handler_sort',
  93. ),
  94. );
  95. // Query timer field.
  96. $data['performance_detail']['query_timer'] = array(
  97. 'title' => t('Query timer'),
  98. 'help' => t('Amount of milliseconds spent on queries for this page.'),
  99. 'field' => array(
  100. 'handler' => 'views_handler_field_numeric',
  101. 'click sortable' => TRUE,
  102. ),
  103. 'filter' => array(
  104. 'handler' => 'views_handler_filter_numeric',
  105. ),
  106. 'sort' => array(
  107. 'handler' => 'views_handler_sort',
  108. ),
  109. );
  110. // Anonymous user field.
  111. $data['performance_detail']['anon'] = array(
  112. 'title' => t('Anonymous user?'),
  113. 'help' => t('Whether the access was by an anonymous user or not.'),
  114. 'field' => array(
  115. 'handler' => 'views_handler_field_boolean',
  116. 'click sortable' => TRUE,
  117. ),
  118. 'filter' => array(
  119. 'handler' => 'views_handler_filter_boolean_operator',
  120. 'label' => t('Anonymous?'),
  121. 'type' => 'yes-no',
  122. // use boolean_field = 1 instead of boolean_field <> 0 in WHERE statment
  123. 'use equal' => TRUE,
  124. ),
  125. 'sort' => array(
  126. 'handler' => 'views_handler_sort',
  127. ),
  128. );
  129. // Path field.
  130. $data['performance_detail']['path'] = array(
  131. 'title' => t('Path'),
  132. 'help' => t('The path of the page for which detailed performance logging was stored.'),
  133. 'field' => array(
  134. 'handler' => 'views_handler_field',
  135. 'click sortable' => TRUE,
  136. ),
  137. 'sort' => array(
  138. 'handler' => 'views_handler_sort',
  139. ),
  140. 'filter' => array(
  141. 'handler' => 'views_handler_filter_string',
  142. ),
  143. 'argument' => array(
  144. 'handler' => 'views_handler_argument_string',
  145. ),
  146. );
  147. return $data;
  148. }