- move getProjectsWithLabelCounts to IDF_Views (where the other functions
reside as well) and make it static - refactor out the code from getProjects that determines which projects are visible by a user and use the same code to restrict the count that we calculate for all available project tags - calculating the project stats is now no longer O(5n) but simply O(5) when it comes to SQL queries (where n is the number of filtered projects); remove the member statistic since it makes no sense in this context
This commit is contained in:
@@ -52,31 +52,6 @@ class IDF_Forge
|
||||
$this->conf->setVal('project_labels', $labels);
|
||||
}
|
||||
|
||||
public function getProjectLabelsWithCounts() {
|
||||
$sql = new Pluf_SQL('project IS NULL');
|
||||
$tagList = Pluf::factory('IDF_Tag')->getList(array(
|
||||
'filter' => $sql->gen(),
|
||||
'view' => 'join_projects',
|
||||
'order' => 'class ASC, lcname ASC'
|
||||
));
|
||||
|
||||
$maxProjectCount = 0;
|
||||
foreach ($tagList as $tag) {
|
||||
$maxProjectCount = max($maxProjectCount, $tag->project_count);
|
||||
}
|
||||
|
||||
$tags = array();
|
||||
foreach ($tagList as $tag) {
|
||||
// group by class
|
||||
if (!array_key_exists($tag->class, $tags)) {
|
||||
$tags[$tag->class] = array();
|
||||
}
|
||||
$tag->rel_project_count = $tag->project_count / (double) $maxProjectCount;
|
||||
$tags[$tag->class][] = $tag;
|
||||
}
|
||||
return $tags;
|
||||
}
|
||||
|
||||
public function setCustomForgePageEnabled($enabled) {
|
||||
$this->conf->setVal('custom_forge_page_enabled', $enabled);
|
||||
}
|
||||
|
Reference in New Issue
Block a user