Index: trunk/extensions/ArticleAssessmentPilot/api/ApiListArticleAssessment.php |
— | — | @@ -49,6 +49,8 @@ |
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
| 53 | + $this->addOption( 'ORDER BY', 'aa_revision DESC' ); |
| 54 | + |
53 | 55 | $limit = $params['limit']; |
54 | 56 | $this->addOption( 'LIMIT', $limit * 4 ); //4 "Ratings" |
55 | 57 | |
— | — | @@ -66,8 +68,8 @@ |
67 | 69 | 'pageid' => $pageId, |
68 | 70 | ); |
69 | 71 | |
70 | | - if ( isset( $params['revid'] ) ){ |
71 | | - $page['revid'] = $row->aa_revision ; |
| 72 | + if ( isset( $params['revid'] ) || $params['userrating'] ){ |
| 73 | + $page['revid'] = $row->aa_revision; |
72 | 74 | } |
73 | 75 | |
74 | 76 | $ratings[$pageId] = $page; |
— | — | @@ -90,15 +92,16 @@ |
91 | 93 | } |
92 | 94 | |
93 | 95 | //Only can actually be "stale" if the user has rated the article before |
94 | | - //We need a target revision to be able to calculate "stale" against |
95 | | - if ( $params['userrating'] && $userRatedArticle && $params['revid'] ) { |
| 96 | + if ( $params['userrating'] && $userRatedArticle ) { |
| 97 | + $revid = isset( $params['revid'] ) ? $params['revid'] : $ratings[$pageId]['revid']; |
| 98 | + |
96 | 99 | $this->resetQueryParams(); |
97 | 100 | |
98 | 101 | $this->addTables( 'revision' ); |
99 | 102 | $this->addFields( array( 'COUNT(rev_id) AS norevs', 'rev_page' ) ); |
100 | 103 | |
101 | 104 | $this->addWhereFld( 'rev_page', $params['pageid'] ); |
102 | | - $this->addWhere( 'rev_id > ' . $params['revid'] ); |
| 105 | + $this->addWhere( 'rev_id > ' . $revid ); |
103 | 106 | |
104 | 107 | $res = $this->select( __METHOD__ ); |
105 | 108 | |