diff --git a/ext/tag_list/main.php b/ext/tag_list/main.php index 60e82026..6299c7fa 100644 --- a/ext/tag_list/main.php +++ b/ext/tag_list/main.php @@ -88,21 +88,21 @@ class TagList extends Extension { global $config; $tags_min = $config->get_int('tags_min'); - $result = $database->Execute( - "SELECT tag,count FROM tags WHERE count > ? ORDER BY tag", - array($tags_min)); + $tag_data = $database->cache_execute(300, " + SELECT + tag, + FLOOR(LOG(LOG(count - ? + 1)+1)*1.5*100)/100 AS scaled + FROM tags + WHERE count > ? + ORDER BY tag + ", array($tags_min, $tags_min))->GetArray(); $html = ""; - while(!$result->EOF) { - $row = $result->fields; + foreach($tag_data as $row) { $h_tag = html_escape($row['tag']); - $count = $row['count']; - if($count > 1) { - $size = floor(log(log($row['count'] - $tags_min + 1)+1)*1.5*100)/100; - $link = $this->tag_link($row['tag']); - $html .= " $h_tag \n"; - } - $result->MoveNext(); + $size = $row['scaled']; + $link = $this->tag_link($row['tag']); + $html .= " $h_tag \n"; } return $html; } @@ -112,14 +112,13 @@ class TagList extends Extension { global $config; $tags_min = $config->get_int('tags_min'); - $result = $database->Execute( + $tag_data = $database->cache_execute(300, "SELECT tag,count FROM tags WHERE count > ? ORDER BY tag", - array($tags_min)); + array($tags_min))->GetArray(); $html = ""; $lastLetter = 0; - while(!$result->EOF) { - $row = $result->fields; + foreach($tag_data as $row) { $h_tag = html_escape($row['tag']); $count = $row['count']; if($lastLetter != strtolower(substr($h_tag, 0, 1))) { @@ -128,7 +127,6 @@ class TagList extends Extension { } $link = $this->tag_link($row['tag']); $html .= "$h_tag ($count)\n"; - $result->MoveNext(); } return $html; @@ -139,24 +137,22 @@ class TagList extends Extension { global $config; $tags_min = $config->get_int('tags_min'); - $result = $database->Execute( - "SELECT tag,count FROM tags WHERE count > ? ORDER BY count DESC, tag ASC", - array($tags_min) - ); + $tag_data = $database->cache_execute(300, + "SELECT tag,count,FLOOR(LOG(count)) AS scaled FROM tags WHERE count > ? ORDER BY count DESC, tag ASC", + array($tags_min))->GetArray(); $html = "Results grouped by loge(n)"; $lastLog = 0; - while(!$result->EOF) { - $row = $result->fields; + foreach($tag_data as $row) { $h_tag = html_escape($row['tag']); $count = $row['count']; - if($lastLog != floor(log($count))) { - $lastLog = floor(log($count)); + $scaled = $row['scaled']; + if($lastLog != $scaled) { + $lastLog = $scaled; $html .= "
$lastLog
";
}
$link = $this->tag_link($row['tag']);
$html .= "$h_tag ($count)\n";
- $result->MoveNext();
}
return $html;