Niharika29 has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/198233

Change subject: Fix aggregated reports to work on the new reviews system
......................................................................

Fix aggregated reports to work on the new reviews system

Bug: T93251
Change-Id: I159ae76915db15cfbb5f26006529608ea43b4ea8
---
M src/Controllers/Reports/Aggregated.php
M src/Dao/Reports.php
2 files changed, 39 insertions(+), 55 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/iegreview 
refs/changes/33/198233/1

diff --git a/src/Controllers/Reports/Aggregated.php 
b/src/Controllers/Reports/Aggregated.php
index b3aec85..8b0b5d8 100644
--- a/src/Controllers/Reports/Aggregated.php
+++ b/src/Controllers/Reports/Aggregated.php
@@ -57,34 +57,6 @@
                                'sortable' => true,
                                'sortcolumn' => 'amount',
                        ),
-                       'report-aggregated-impact' => array(
-                               'column' => 'impact',
-                               'format' => 'number',
-                               'precision' => 2,
-                               'sortable' => true,
-                               'sortcolumn' => 'impact',
-                       ),
-                       'report-aggregated-innovation' => array(
-                               'column' => 'innovation',
-                               'format' => 'number',
-                               'precision' => 2,
-                               'sortable' => true,
-                               'sortcolumn' => 'innovation',
-                       ),
-                       'report-aggregated-ability' => array(
-                               'column' => 'ability',
-                               'format' => 'number',
-                               'precision' => 2,
-                               'sortable' => true,
-                               'sortcolumn' => 'ability',
-                       ),
-                       'report-aggregated-engagement' => array(
-                               'column' => 'engagement',
-                               'format' => 'number',
-                               'precision' => 2,
-                               'sortable' => true,
-                               'sortcolumn' => 'engagement',
-                       ),
                        'report-aggregated-recommend' => array(
                                'format' => 'message',
                                'message' => 'report-format-recommend',
@@ -115,6 +87,6 @@
                        'items' => $this->form->get( 'items' ),
                        'page' => $this->form->get( 'p' ),
                );
-               return $this->dao->aggregatedScores( $params );
+               return $this->dao->aggregatedScores( $this->activeCampaign, 
$params );
        }
 }
diff --git a/src/Dao/Reports.php b/src/Dao/Reports.php
index 13d256a..87fc627 100644
--- a/src/Dao/Reports.php
+++ b/src/Dao/Reports.php
@@ -52,10 +52,11 @@
        }
 
        /**
+        * @param int $campaign Active campaign ID
         * @param array $params
         * @return object StdClass with rows and found memebers
         */
-       public function aggregatedScores( array $params ) {
+       public function aggregatedScores( $campaign, array $params ) {
                $this->logger->debug( __METHOD__, $params );
                $defaults = array(
                        'sort' => 'pcnt',
@@ -67,7 +68,7 @@
 
                $validSorts = array(
                        'id', 'title', 'amount', 'theme',
-                       'impact', 'innovation', 'ability', 'engagement', 
'recommend',
+                       //'impact', 'innovation', 'ability', 'engagement', 
'recommend',
                        'rcnt', 'pcnt',
                );
                $sortby = in_array( $params['sort'], $validSorts ) ?
@@ -75,7 +76,7 @@
                $order = $params['order'] === 'desc' ? 'DESC' : 'ASC';
 
                $crit = array();
-
+               $crit['campaign'] = $campaign;
                if ( $params['items'] == 'all' ) {
                        $limit = '';
                        $offset = '';
@@ -85,30 +86,41 @@
                        $limit = 'LIMIT :int_limit';
                        $offset = 'OFFSET :int_offset';
                }
-
+               //die(print_r($crit));
+               $fields = array(
+                       'p.id',
+                       'p.title',
+                       'p.theme',
+                       'p.amount'
+               );
                $sql = self::concat(
-                       'SELECT p.id, p.title, p.theme, p.amount,',
-                       'r.impact,',
-                       'r.innovation,',
-                       'r.ability,',
-                       'r.engagement,',
-                       'r.recommend,',
-                       'IF(r.conditional >0, \'*\', \'\') AS conditional,',
-                       'r.cnt AS rcnt,',
-                       'ROUND((r.recommend / r.cnt) * 100, 2) AS pcnt',
-                       'FROM proposals p',
-                       'INNER JOIN (',
-                               'SELECT COUNT(*) AS cnt,',
-                               'AVG(impact) AS impact,',
-                               'AVG(innovation) AS innovation,',
-                               'AVG(ability) AS ability,',
-                               'AVG(engagement) AS engagement,',
-                               'SUM(IF(recommendation > 0, 1, 0)) AS 
recommend,',
-                               'SUM(IF(recommendation = 1, 1, 0)) AS 
conditional,',
-                               'proposal',
-                               'FROM reviews',
-                               'GROUP BY proposal',
-                       ') r ON p.id = r.proposal',
+//                     'SELECT p.id, p.title, p.theme, p.amount,',
+//                     'r.impact,',
+//                     'r.innovation,',
+//                     'r.ability,',
+//                     'r.engagement,',
+//                     'r.recommend,',
+//                     'IF(r.conditional >0, \'*\', \'\') AS conditional,',
+//                     'r.cnt AS rcnt,',
+//                     'ROUND((r.recommend / r.cnt) * 100, 2) AS pcnt',
+//                     'FROM proposals p',
+//                     'INNER JOIN (',
+//                             'SELECT COUNT(*) AS cnt,',
+//                             'AVG(impact) AS impact,',
+//                             'AVG(innovation) AS innovation,',
+//                             'AVG(ability) AS ability,',
+//                             'AVG(engagement) AS engagement,',
+//                             'SUM(IF(recommendation > 0, 1, 0)) AS 
recommend,',
+//                             'SUM(IF(recommendation = 1, 1, 0)) AS 
conditional,',
+//                             'proposal',
+//                             'FROM reviews',
+//                             'GROUP BY proposal',
+//                     ') r ON p.id = r.proposal',
+                       'SELECT DISTINCT', implode( ',', $fields ), 'FROM 
proposals p',
+                       'INNER JOIN review_questions rq ON rq.campaign = 
p.campaign',
+                       'INNER JOIN review_answers ra ON ra.question = rq.id',
+                       'WHERE p.campaign = :campaign',
+                       'AND rq.type = "recommend"',
                        "ORDER BY {$sortby} {$order}, id {$order}",
                        $limit, $offset
                );

-- 
To view, visit https://gerrit.wikimedia.org/r/198233
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I159ae76915db15cfbb5f26006529608ea43b4ea8
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/iegreview
Gerrit-Branch: master
Gerrit-Owner: Niharika29 <niharikakohl...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to