svn: /web/php-bugs/trunk/include/ query.php
| From: | Felipe Pena | Date: | Sat, 14 Aug 2010 16:50:28 +0000 |
| Subject: | svn: /web/php-bugs/trunk/include/ query.php | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-8742@lists.php.net to get a copy of this message | ||
felipe Sat, 14 Aug 2010 16:50:28 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=302227
Log:
- Added order by number of votes
Changed paths:
U web/php-bugs/trunk/include/query.php
Modified: web/php-bugs/trunk/include/query.php
===================================================================
--- web/php-bugs/trunk/include/query.php 2010-08-14 16:37:00 UTC (rev 302226)
+++ web/php-bugs/trunk/include/query.php 2010-08-14 16:50:28 UTC (rev 302227)
@@ -14,7 +14,8 @@
'php_os' => 'os',
'sdesc' => 'summary',
'assign' => 'assignment',
- 'avg_score' => 'avg. vote score'
+ 'avg_score' => 'avg. vote score',
+ 'votes_count' => 'number of votes'
);
// Fetch pseudo packages
@@ -55,7 +56,7 @@
FROM bugdb
';
- if ($order_by == 'avg_score') {
+ if (in_array($order_by, array('votes_count', 'avg_score'))) {
$query .= 'LEFT JOIN bugdb_votes v ON bugdb.id = v.bug';
}
@@ -188,13 +189,22 @@
}
}
- if ($order_by == 'avg_score') {
+ if (in_array($order_by, array('votes_count', 'avg_score'))) {
$query .= ' GROUP BY bugdb.id';
- $order_by = 'IFNULL(AVG(v.score), 0)+3';
+
+ switch ($order_by) {
+ case 'avg_score':
+ $order_by = "IFNULL(AVG(v.score), 0)+3 $direction, COUNT(v.bug) DESC";
+ break;
+ case 'votes_count':
+ $order_by = "COUNT(v.bug) $direction";
+ break;
+ }
+ $query .= " ORDER BY $order_by";
+ } else {
+ $query .= " ORDER BY $order_by $direction";
}
-
- $query .= " ORDER BY $order_by $direction";
-
+
// if status Feedback then sort also after last updated time.
if ($status == 'Feedback') {
$query .= ", bugdb.ts2 $direction";