r105464 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105463‎ | r105464 | r105465 >
Date:22:02, 7 December 2011
Author:gregchiasson
Status:resolved (Comments)
Tags:
Comment:
AFTv5 - per code review, the fetchRollup query was way more complicated than it had to be. Not sure what I was thinking with that one, but I'm guessing I wrote it late at night and wasn't thinking straight. Anyway, fixed now, and the ratings fetch API call should be a bit faster..
Modified paths:
  • /trunk/extensions/ArticleFeedbackv5/api/ApiViewRatingsArticleFeedbackv5.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedbackv5/api/ApiViewRatingsArticleFeedbackv5.php
@@ -45,8 +45,8 @@
4646 $info[$row->field_name] = array(
4747 'ratingdesc' => $row->field_name,
4848 'ratingid' => (int) $row->field_id,
49 - 'total' => (int) $row->points,
50 - 'count' => (int) $row->reviews,
 49+ 'total' => (int) $row->arr_total,
 50+ 'count' => (int) $row->add_count,
5151 );
5252 }
5353 $result->addValue( $result_path, 'rollup', $info );
@@ -58,28 +58,26 @@
5959 * @param $pageId int the page id
6060 * @param $revisionLimit int go back only to this revision
6161 * @param $type string the type of row to fetch ('page' or 'revision')
62 - * @return array the rollup row
 62+ * @return array the rollup rows
6363 */
6464 private function fetchRollup( $pageId, $revisionLimit, $type ) {
6565 $dbr = wfGetDB( DB_SLAVE );
6666 $where = array();
6767 $table = 'article_feedback_ratings_rollup';
68 - $prefix = 'arr';
69 - $where[$prefix . '_page_id'] = $pageId;
70 - $where[] = $prefix . '_rating_id = afi_id';
 68+ $where['arr_page_id'] = $pageId;
 69+ $where[] = 'arr_rating_id = afi_id';
7170 $rows = $dbr->select(
72 - array( 'aft_' . $table, 'aft_article_field' ),
 71+ array(
 72+ 'aft_article_feedback_ratings_rollup',
 73+ 'aft_article_field' ),
7374 array(
7475 'afi_name AS field_name',
75 - $prefix . '_rating_id AS field_id',
76 - 'SUM(' . $prefix . '_total) AS points',
77 - 'SUM(' . $prefix . '_count) AS reviews',
 76+ 'arr_rating_id AS field_id',
 77+ 'arr_total',
 78+ 'arr_count',
7879 ),
7980 $where,
8081 __METHOD__,
81 - array(
82 - 'GROUP BY' => $prefix . '_rating_id, afi_name'
83 - )
8482 );
8583
8684 return $rows;
@@ -94,7 +92,6 @@
9593 return array(
9694 'pageid' => array(
9795 ApiBase::PARAM_REQUIRED => true,
98 - ApiBase::PARAM_ISMULTI => false,
9996 ApiBase::PARAM_TYPE => 'integer',
10097 )
10198 );

Follow-up revisions

RevisionCommit summaryAuthorDate
r106066AFTv5 - fix typo in r105464 that was making ratings fetches not work.gregchiasson19:17, 13 December 2011

Comments

#Comment by Catrope (talk | contribs)   16:50, 12 December 2011
+				'count'      => (int) $row->add_count,

Typo, needs to be arr_count. Marking fixme for this; OK otherwise.

Status & tagging log