r85914 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85913‎ | r85914 | r85915 >
Date:20:26, 12 April 2011
Author:tparscal
Status:ok
Tags:
Comment:
Removed dependence on sorting to get properties from the most current revision, now pulling them from the sam revision that the user ratings are from - should be much faster. See r85483
Modified paths:
  • /trunk/extensions/ArticleFeedback/api/ApiQueryArticleFeedback.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedback/api/ApiQueryArticleFeedback.php
@@ -55,11 +55,6 @@
5656 // User-specific data
5757 $ratings[$params['pageid']]['status'] = 'current';
5858 if ( $params['userrating'] ) {
59 - // Expertise
60 - $expertise = $this->getExpertise( $params );
61 - if ( $expertise !== false ) {
62 - $ratings[$params['pageid']]['expertise'] = $expertise;
63 - }
6459 // User ratings
6560 $userRatings = $this->getUserRatings( $params );
6661 if ( isset( $ratings[$params['pageid']]['ratings'] ) ) {
@@ -101,6 +96,13 @@
10297 );
10398 }
10499 }
 100+ // Expertise
 101+ if ( isset( $ratings[$params['pageid']]['revid'] ) ) {
 102+ $expertise = $this->getExpertise( $params, $ratings[$params['pageid']]['revid'] );
 103+ if ( $expertise !== false ) {
 104+ $ratings[$params['pageid']]['expertise'] = $expertise;
 105+ }
 106+ }
105107 }
106108
107109 foreach ( $ratings as $rat ) {
@@ -149,7 +151,7 @@
150152 return $token;
151153 }
152154
153 - protected function getExpertise( $params ) {
 155+ protected function getExpertise( $params, $revid ) {
154156 global $wgUser;
155157
156158 return $this->getDB()->selectField(
@@ -159,9 +161,9 @@
160162 'afp_key' => 'expertise',
161163 'afp_user_text' => $wgUser->getName(),
162164 'afp_user_anon_token' => $this->getAnonToken( $params ),
 165+ 'afp_revision' => $revid,
163166 ),
164 - __METHOD__,
165 - array( 'ORDER BY', 'afp_revision DESC' )
 167+ __METHOD__
166168 );
167169 }
168170

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r85483Split expertise query into it's own method, since it's logged per revision no...tparscal22:59, 5 April 2011

Status & tagging log