Commit 1ad71e38 authored by Simon Welsh's avatar Simon Welsh

Adds Penis and total stats

git-svn-id: svn+ssh://lsgn/var/logbot-www@75 5f99df0c-6b0a-442a-b40a-040688e84a9d
parent f5bf9535
......@@ -126,8 +126,9 @@ function build_stats(Redis $r) {
'Presto',
'ffs',
'wtf',
'Penis',
];
$query = 'SELECT COUNT(*) AS "Number", "Nick" FROM "Log" WHERE "Text" ILIKE \'%%%s%%\' GROUP BY "Nick" HAVING COUNT(*) >= 10 ORDER BY "Number" DESC;';
$query = 'SELECT COUNT(*) AS "Number", "Nick" FROM "Log" WHERE "Text" ILIKE \'%%%s%%\' GROUP BY "Nick" HAVING COUNT(*) >= 10 ORDER BY "Number" DESC LIMIT 50;';
foreach($swears as $name) {
$res = DB::inst()->query(sprintf($query, $name));
$stats[$name] = [];
......@@ -139,5 +140,11 @@ function build_stats(Redis $r) {
uasort($stats, function($b, $a) {
return count($a) - count($b);
});
$r->set('log:stats', $stats, 3600);
$full = [];
$query = 'SELECT COUNT(*) AS "Number", "Nick" FROM "Log" WHERE "Command" = \'ACTION\' OR "Command" = \'PRIVMSG\' GROUP BY "Nick" ORDER BY "Number" DESC LIMIT 50;';
$res = DB::inst()->query($query);
while($row = pg_fetch_array($res)) {
$full[$row[1]] = $row[0];
}
$r->set('log:stats', [$full, $stats], 3600);
}
......@@ -14,7 +14,23 @@ $body = <x:frag>
$stats = get_stats();
foreach($stats as $name => $values) {
$d = <div class="swear"><h3>Top speakers</h3></div>;
$tb = <tbody />;
foreach($stats[0] as $person => $count) {
$tb->appendChild(<tr><td>{$person}</td><td>{$count}</td></tr>);
}
$d->appendChild(<table>
<thead>
<tr>
<th>Nick</th><th>Number of lines</th>
</tr>
</thead>
{$tb}
</table>);
$body->appendChild($d);
foreach($stats[1] as $name => $values) {
$d = <div class="swear" />;
$d->appendChild(<h3 id={strtolower($name)}>{$name}</h3>);
$tb = <tbody />;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment