Index: trunk/extensions/ArticleAssessmentPilot/api/ApiListArticleAssessment.php |
— | — | @@ -105,24 +105,23 @@ |
106 | 106 | if ( $params['userrating'] && $userRatedArticle ) { |
107 | 107 | $revid = isset( $params['revid'] ) ? $params['revid'] : $ratings[$pageId]['revid']; |
108 | 108 | |
109 | | - $this->resetQueryParams(); |
| 109 | + $dbr = wfGetDb( DB_SLAVE ); |
110 | 110 | |
111 | | - $this->addTables( 'revision' ); |
112 | | - $this->addFields( array( 'COUNT(rev_id) AS norevs', 'rev_page' ) ); |
| 111 | + $res = $dbr->selectField( |
| 112 | + 'revision', |
| 113 | + 'COUNT(*) AS norevs', |
| 114 | + array( |
| 115 | + 'rev_page' => $params['pageid'], |
| 116 | + 'rev_id > ' . $revid |
| 117 | + ), |
| 118 | + __METHOD__ |
| 119 | + ); |
113 | 120 | |
114 | | - $this->addWhereFld( 'rev_page', $params['pageid'] ); |
115 | | - $this->addWhere( 'rev_id > ' . $revid ); |
116 | | - |
117 | | - $res = $this->select( __METHOD__ ); |
118 | | - |
119 | 121 | global $wgArticleAssessmentStaleCount; |
120 | 122 | |
121 | | - if ( $res ) { |
122 | | - $noOfRevs = $res->fetchRow()->norevs; |
123 | | - if ( $noOfRevs > $wgArticleAssessmentStaleCount ) { |
124 | | - //it's stale! |
125 | | - $ratings[$params['pageid']]['stale'] = intval( $noOfRevs ); |
126 | | - } |
| 123 | + if ( $res && (int)$res > $wgArticleAssessmentStaleCount ) { |
| 124 | + //it's stale! |
| 125 | + $ratings[$params['pageid']]['stale'] = intval( $res ); |
127 | 126 | } |
128 | 127 | } |
129 | 128 | |
— | — | @@ -187,7 +186,7 @@ |
188 | 187 | return array( |
189 | 188 | 'api.php?action=query&list=articleassessment', |
190 | 189 | 'api.php?action=query&list=articleassessment&aapageid=1', |
191 | | - 'api.php?action=query&list=articleassessment&aapageid=1&userrating', |
| 190 | + 'api.php?action=query&list=articleassessment&aapageid=1&aauserrating', |
192 | 191 | ); |
193 | 192 | } |
194 | 193 | |