r72532 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72531‎ | r72532 | r72533 >
Date:12:25, 7 September 2010
Author:reedy
Status:resolved (Comments)
Tags:
Comment:
ApiArticleAssessment:
*Finish function comments

ApiQueryArticleAssessment:
*Drop useless limit parameter
*Make revid integer, and not multi
*Limit COUNT of revisions to $wgArticleAssessmentStaleCount + 1 (Funny how I'd done the limit in a similar query... Oh well)
*LIMIT instead to $wgArticleAssessmentRatingCount, rather than hard coded value (to be changed to count of array I suppose after more rework)
Modified paths:
  • /trunk/extensions/ArticleAssessmentPilot/api/ApiArticleAssessment.php (modified) (history)
  • /trunk/extensions/ArticleAssessmentPilot/api/ApiQueryArticleAssessment.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleAssessmentPilot/api/ApiQueryArticleAssessment.php
@@ -54,9 +54,10 @@
5555
5656 $this->addOption( 'ORDER BY', 'aa_revision DESC' );
5757 }
 58+
 59+ global $wgArticleAssessmentRatingCount;
5860
59 - $limit = $params['limit'];
60 - $this->addOption( 'LIMIT', $limit * 4 ); //4 "Ratings"
 61+ $this->addOption( 'LIMIT', $wgArticleAssessmentRatingCount );
6162
6263 $res = $this->select( __METHOD__ );
6364
@@ -100,6 +101,8 @@
101102 $revid = isset( $params['revid'] ) ? $params['revid'] : $ratings[$pageId]['revid'];
102103
103104 $dbr = wfGetDb( DB_SLAVE );
 105+
 106+ global $wgArticleAssessmentStaleCount;
104107
105108 $res = $dbr->selectField(
106109 'revision',
@@ -108,11 +111,10 @@
109112 'rev_page' => $params['pageid'],
110113 'rev_id > ' . $revid
111114 ),
112 - __METHOD__
 115+ __METHOD__,
 116+ array ( 'LIMIT', $wgArticleAssessmentStaleCount + 1 )
113117 );
114118
115 - global $wgArticleAssessmentStaleCount;
116 -
117119 if ( $res && (int)$res > $wgArticleAssessmentStaleCount ) {
118120 //it's stale!
119121 $ratings[$params['pageid']]['stale'] = intval( $res );
@@ -139,16 +141,12 @@
140142 ApiBase::PARAM_ISMULTI => false,
141143 ApiBase::PARAM_TYPE => 'integer',
142144 ),
143 - 'revid' => null,
 145+ 'revid' =>array(
 146+ ApiBase::PARAM_ISMULTI => false,
 147+ ApiBase::PARAM_TYPE => 'integer',
 148+ ),
144149 'userrating' => false,
145150 'anontoken' => null,
146 - 'limit' => array(
147 - ApiBase::PARAM_DFLT => 1,
148 - ApiBase::PARAM_TYPE => 'limit',
149 - ApiBase::PARAM_MIN => 1,
150 - ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
151 - ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG1,
152 - ),
153151 );
154152 }
155153
@@ -158,7 +156,6 @@
159157 'revid' => 'Specific revision to get (used in conjunction with userrating param, otherwise ignored)',
160158 'userrating' => "Whether to get the current user's ratings for the specific rev/article",
161159 'anontoken' => 'Token for anonymous users',
162 - 'limit' => 'Amount of pages to get the ratings for',
163160 );
164161 }
165162
Index: trunk/extensions/ArticleAssessmentPilot/api/ApiArticleAssessment.php
@@ -73,9 +73,10 @@
7474 }
7575
7676 /**
77 - *
78 - * @param $pageId Integer:
79 - * @param $ratingId Integer:
 77+ * Inserts (or Updates, where appropriate) the aggregate page rating
 78+ *
 79+ * @param $pageId Integer: Page Id
 80+ * @param $ratingId Integer: Rating Id
8081 * @param $updateAddition Integer: Difference between user's last rating (if applicable)
8182 * @param $newRating Boolean: Whether this is a new rating (for update, whether this increases the count)
8283 */
@@ -109,12 +110,14 @@
110111 }
111112
112113 /**
113 - * @param $pageId Integer:
114 - * @param $revisionId Integer:
115 - * @param $user User:
116 - * @param $token Array:
117 - * @param $ratingId Integer:
118 - * @param $ratingValue Integer:
 114+ * Inserts (or Updates, where appropriate) the users ratings for a specific revision
 115+ *
 116+ * @param $pageId Integer: Page Id
 117+ * @param $revisionId Integer: Revision Id
 118+ * @param $user User: Current User object
 119+ * @param $token Array: Token if necessary
 120+ * @param $ratingId Integer: Rating Id
 121+ * @param $ratingValue Integer: Value of the Rating
119122 */
120123 private function insertUserRatings( $pageId, $revisionId, $user, $token, $ratingId, $ratingValue ) {
121124 $dbw = wfGetDB( DB_MASTER );

Follow-up revisions

RevisionCommit summaryAuthorDate
r72623Followup r72532, actually follow what the CR notes suggested, use limit fetch...reedy01:15, 9 September 2010

Comments

#Comment by Catrope (talk | contribs)   20:23, 7 September 2010
+				array ( 'LIMIT', $wgArticleAssessmentStaleCount + 1 )

This doesn't work. LIMIT affects the number of rows returned, which is always 1 for your query. It does not affect how many rows COUNT() scans.

#Comment by Reedy (talk | contribs)   23:33, 7 September 2010

Blah

Status & tagging log