r72044 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72043‎ | r72044 | r72045 >
Date:20:20, 31 August 2010
Author:reedy
Status:deferred
Tags:
Comment:
Add "stale" rating notification to ArticleAssessmentPilot
Modified paths:
  • /trunk/extensions/ArticleAssessmentPilot/ArticleAssessmentPilot.php (modified) (history)
  • /trunk/extensions/ArticleAssessmentPilot/api/ApiListArticleAssessment.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleAssessmentPilot/ArticleAssessmentPilot.php
@@ -2,8 +2,8 @@
33
44 // settings
55
6 -// number of reviews
7 -$wgArticleAssessmentRevisionCutoff = 5;
 6+// number of new revisions to mark the last rating as old
 7+$wgArticleAssessmentStaleCount = 5;
88
99 // Number of "ratings" to store. Allows it to be a bit more dynamic
1010 $wgArticleAssessmentRatingCount = 4;
Index: trunk/extensions/ArticleAssessmentPilot/api/ApiListArticleAssessment.php
@@ -56,6 +56,8 @@
5757
5858 $ratings = array();
5959
 60+ $userRatedArticle = false;
 61+
6062 foreach ( $res as $row ) {
6163 $pageId = $row->aap_page_id;
6264
@@ -80,11 +82,33 @@
8183
8284 if ( $params['userrating'] && !is_null( $row->aa_rating_value ) ) {
8385 $thisRow['userrating'] = $row->aa_rating_value;
 86+
 87+ $userRatedArticle = true;
8488 }
8589
8690 $ratings[$pageId]['ratings'][] = $thisRow;
8791 }
8892
 93+ //Only can actually be "stale" if the user has rated the article before
 94+ if ( $params['userrating'] && $userRatedArticle ) {
 95+ $this->resetQueryParams();
 96+
 97+ $this->addTables( 'revision' );
 98+ $this->addFields( array( 'COUNT(rev_id) AS norevs', 'rev_page' ) );
 99+
 100+ $this->addWhereFld( 'rev_page', $params['pageid'] );
 101+ $this->addWhere( 'rev_id > ' . $params['revid'] );
 102+
 103+ $res = $this->select( __METHOD__ );
 104+
 105+ global $wgArticleAssessmentStaleCount;
 106+
 107+ if ( $res && $res[0]->norevs > $wgArticleAssessmentStaleCount ){
 108+ //it's stale!
 109+ $ratings[$params['pageid']]['stale'] = '';
 110+ }
 111+ }
 112+
89113 $count = 0;
90114 foreach ( $ratings as $rat ) {
91115 if ( ++ $count > $limit ) {
@@ -101,7 +125,10 @@
102126
103127 public function getAllowedParams() {
104128 return array(
105 - 'pageid' => null,
 129+ 'pageid' => array(
 130+ ApiBase::PARAM_ISMULTI => false,
 131+ ApiBase::PARAM_TYPE => 'integer',
 132+ ),
106133 'revid' => null,
107134 'userrating' => false,
108135 'limit' => array(

Follow-up revisions

RevisionCommit summaryAuthorDate
r72047Can only where on the revid, if we have one... r72044reedy20:50, 31 August 2010

Status & tagging log