Permalink
Browse files

table view now supports anonymized mode

  • Loading branch information...
1 parent 2c18f69 commit 56fcf43faf92ef0deb9115dd1a1fd159c1c8c674 asher committed Feb 12, 2013
Showing with 21 additions and 4 deletions.
  1. +2 −1 README.markdown
  2. +11 −3 table.php
  3. +8 −0 table.tpl
View
@@ -17,4 +17,5 @@ Simply create a `conf.php` file using the sample as a guide and copy the files i
## Authors
* Mikhail Panchenko
* Tim Denike
-* JS graph code by Ross Harmes
+* Asher Feldman
+* JS graph code by Ross Harmes
View
@@ -9,24 +9,32 @@
$hours = mysql_real_escape_string($_GET['hours']);
$q = "SELECT
- t.sample as query, sum(h.ts_cnt) as count, t.checksum as checksum
+ t.sample as query, sum(h.ts_cnt) as count, t.checksum as checksum, t.fingerprint as fingerprint
from
{$host_conf['db_query_review_table']} as t
join
{$host_conf['db_query_review_history_table']} as h
on
t.checksum=h.checksum
where
- t.sample like '% {$table} %'
+ t.sample like '%{$table}%'
AND
h.ts_max > date_sub(now(),interval {$hours} hour)
group by t.checksum order by count desc";
$result=mysql_query($q);
-
$rows = array();
while ($row = mysql_fetch_assoc($result)) {
+ if ($conf['anon']) {
+ if (preg_match('@/\* (\S+)(::\S+)?.*\*/@', $row['sample'], $matches)) {
+ $c = ($matches[2]) ? $matches[1] . $matches[2] : $matches[1];
+ $row['query'] = '/* ' . $c . ' */ ' . $row['fingerprint'];
+ } else {
+ $row['query'] = $row['fingerprint'];
+ }
+ }
$row['explain_url'] = "explain.php?" . ish_build_query(array('checksum'=>$row['checksum']));
+ $row['more_url'] = "more.php?" . ish_build_query(array('checksum'=>$row['checksum']));
$rows[] = $row;
}
View
@@ -6,13 +6,21 @@
<tr>
<th>Count</th>
<th>Query</th>
+ <? if ($conf['explain']): ?>
<th>Explain</th>
+ <? else: ?>
+ <th>More</th>
+ <? endif ?>
</tr>
<? foreach ($rows as $row): ?>
<tr <? if ($counter++ % 2): ?>class="alt"<? endif ?>>
<td><?= $row['count']?></td>
<td><?=format_query($row['query']) ?></td>
+ <? if ($conf['explain']): ?>
<td><a href="<?= $row['explain_url'] ?>">explain</a></td>
+ <? else: ?>
+ <td><a href="<?= $row['more_url'] ?>">more</a></td>
+ <? endif ?>
</tr>
<? endforeach?>
</table>

0 comments on commit 56fcf43

Please sign in to comment.