r85967 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85966‎ | r85967 | r85968 >
Date:18:06, 13 April 2011
Author:tparscal
Status:ok
Tags:
Comment:
Switched use of article_feedback_pages to article_feedback_revisions - article_feedback_pages is going to be for grand totals only.
Modified paths:
  • /trunk/extensions/ArticleFeedback/api/ApiArticleFeedback.php (modified) (history)
  • /trunk/extensions/ArticleFeedback/api/ApiQueryArticleFeedback.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedback/api/ApiArticleFeedback.php
@@ -93,13 +93,13 @@
9494
9595 // Try to insert a new "totals" row for this page,rev,rating set
9696 $dbw->insert(
97 - 'article_feedback_pages',
 97+ 'article_feedback_revisions',
9898 array(
99 - 'aap_page_id' => $pageId,
100 - 'aap_total' => 0,
101 - 'aap_count' => 0,
102 - 'aap_rating_id' => $ratingId,
103 - 'aap_revision' => $revisionId,
 99+ 'afr_page_id' => $pageId,
 100+ 'afr_total' => 0,
 101+ 'afr_count' => 0,
 102+ 'afr_rating_id' => $ratingId,
 103+ 'afr_revision' => $revisionId,
104104 ),
105105 __METHOD__,
106106 array( 'IGNORE' )
@@ -113,30 +113,30 @@
114114 if ( $lastRating ) {
115115 // Deduct the previous rating values from the previous "totals" row
116116 $dbw->update(
117 - 'article_feedback_pages',
 117+ 'article_feedback_revisions',
118118 array(
119 - 'aap_total = aap_total - ' . intval( $lastRating ),
120 - 'aap_count = aap_count - 1',
 119+ 'afr_total = afr_total - ' . intval( $lastRating ),
 120+ 'afr_count = afr_count - 1',
121121 ),
122122 array(
123 - 'aap_page_id' => $pageId,
124 - 'aap_rating_id' => $ratingId,
125 - 'aap_revision' => $lastRevision
 123+ 'afr_page_id' => $pageId,
 124+ 'afr_rating_id' => $ratingId,
 125+ 'afr_revision' => $lastRevision
126126 ),
127127 __METHOD__
128128 );
129129 }
130130 // Add this rating's values to the new "totals" row
131131 $dbw->update(
132 - 'article_feedback_pages',
 132+ 'article_feedback_revisions',
133133 array(
134 - 'aap_total' => $thisRating,
135 - 'aap_count' => 1,
 134+ 'afr_total' => $thisRating,
 135+ 'afr_count' => 1,
136136 ),
137137 array(
138 - 'aap_page_id' => $pageId,
139 - 'aap_rating_id' => $ratingId,
140 - 'aap_revision' => $revisionId,
 138+ 'afr_page_id' => $pageId,
 139+ 'afr_rating_id' => $ratingId,
 140+ 'afr_revision' => $revisionId,
141141 ),
142142 __METHOD__
143143 );
@@ -162,15 +162,15 @@
163163 }
164164 // Apply the difference between the previous and new ratings to the current "totals" row
165165 $dbw->update(
166 - 'article_feedback_pages',
 166+ 'article_feedback_revisions',
167167 array(
168 - 'aap_total = aap_total + ' . $updateAddition,
169 - 'aap_count = aap_count + ' . $countChange,
 168+ 'afr_total = afr_total + ' . $updateAddition,
 169+ 'afr_count = afr_count + ' . $countChange,
170170 ),
171171 array(
172 - 'aap_page_id' => $pageId,
173 - 'aap_rating_id' => $ratingId,
174 - 'aap_revision' => $revisionId,
 172+ 'afr_page_id' => $pageId,
 173+ 'afr_rating_id' => $ratingId,
 174+ 'afr_revision' => $revisionId,
175175 ),
176176 __METHOD__
177177 );
Index: trunk/extensions/ArticleFeedback/api/ApiQueryArticleFeedback.php
@@ -11,24 +11,24 @@
1212 $result = $this->getResult();
1313 $revisionLimit = $this->getRevisionLimit( $params['pageid'] );
1414
15 - $this->addTables( array( 'article_feedback_pages', 'article_feedback_ratings' ) );
 15+ $this->addTables( array( 'article_feedback_revisions', 'article_feedback_ratings' ) );
1616 $this->addFields( array(
17 - 'MAX(aap_revision) as aap_revision',
18 - 'SUM(aap_total) as aap_total',
19 - 'SUM(aap_count) as aap_count',
20 - 'aap_rating_id',
 17+ 'MAX(afr_revision) as afr_revision',
 18+ 'SUM(afr_total) as afr_total',
 19+ 'SUM(afr_count) as afr_count',
 20+ 'afr_rating_id',
2121 'aar_rating',
2222 ) );
2323 $this->addJoinConds( array(
2424 'article_feedback_ratings' => array( 'LEFT JOIN', array(
25 - 'aar_id=aap_rating_id',
26 - 'aap_rating_id' => $wgArticleFeedbackRatings,
 25+ 'aar_id=afr_rating_id',
 26+ 'afr_rating_id' => $wgArticleFeedbackRatings,
2727 )
2828 ),
2929 ) );
30 - $this->addWhereFld( 'aap_page_id', $params['pageid'] );
31 - $this->addWhere( 'aap_revision >= ' . $revisionLimit );
32 - $this->addOption( 'GROUP BY', 'aap_rating_id' );
 30+ $this->addWhereFld( 'afr_page_id', $params['pageid'] );
 31+ $this->addWhere( 'afr_revision >= ' . $revisionLimit );
 32+ $this->addOption( 'GROUP BY', 'afr_rating_id' );
3333 $this->addOption( 'LIMIT', count( $wgArticleFeedbackRatings ) );
3434
3535 // Rating counts and totals
@@ -37,18 +37,18 @@
3838 $historicCounts = $this->getHistoricCounts( $params );
3939 foreach ( $res as $i => $row ) {
4040 if ( !isset( $ratings[$params['pageid']]['revid'] ) ) {
41 - $ratings[$params['pageid']]['revid'] = (int) $row->aap_revision;
 41+ $ratings[$params['pageid']]['revid'] = (int) $row->afr_revision;
4242 }
4343 if ( !isset( $ratings[$params['pageid']]['ratings'] ) ) {
4444 $ratings[$params['pageid']]['ratings'] = array();
4545 }
4646 $ratings[$params['pageid']]['ratings'][] = array(
47 - 'ratingid' => (int) $row->aap_rating_id,
 47+ 'ratingid' => (int) $row->afr_rating_id,
4848 'ratingdesc' => $row->aar_rating,
49 - 'total' => (int) $row->aap_total,
50 - 'count' => (int) $row->aap_count,
51 - 'countall' => isset( $historicCounts[$row->aap_rating_id] )
52 - ? (int) $historicCounts[$row->aap_rating_id] : 0
 49+ 'total' => (int) $row->afr_total,
 50+ 'count' => (int) $row->afr_count,
 51+ 'countall' => isset( $historicCounts[$row->afr_rating_id] )
 52+ ? (int) $historicCounts[$row->afr_rating_id] : 0
5353 );
5454 }
5555
@@ -90,8 +90,8 @@
9191 'ratingdesc' => $userRating['text'],
9292 'total' => 0,
9393 'count' => 0,
94 - 'countall' => isset( $historicCounts[$row->aap_rating_id] )
95 - ? (int) $historicCounts[$row->aap_rating_id] : 0,
 94+ 'countall' => isset( $historicCounts[$row->afr_rating_id] )
 95+ ? (int) $historicCounts[$row->afr_rating_id] : 0,
9696 'userrating' => (int) $userRating['value'],
9797 );
9898 }
@@ -117,21 +117,21 @@
118118 global $wgArticleFeedbackRatings;
119119
120120 $res = $this->getDB()->select(
121 - 'article_feedback_pages',
 121+ 'article_feedback_revisions',
122122 array(
123 - 'aap_rating_id',
124 - 'SUM(aap_count) as count',
 123+ 'afr_rating_id',
 124+ 'SUM(afr_count) as count',
125125 ),
126126 array(
127 - 'aap_page_id' => $params['pageid'],
128 - 'aap_rating_id' => $wgArticleFeedbackRatings,
 127+ 'afr_page_id' => $params['pageid'],
 128+ 'afr_rating_id' => $wgArticleFeedbackRatings,
129129 ),
130130 __METHOD__,
131 - array( 'GROUP BY' => 'aap_rating_id')
 131+ array( 'GROUP BY' => 'afr_rating_id')
132132 );
133133 $counts = array();
134134 foreach ( $res as $row ) {
135 - $counts[$row->aap_rating_id] = $row->count;
 135+ $counts[$row->afr_rating_id] = $row->count;
136136 }
137137 return $counts;
138138 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r85969Using article_feedback_pages for historical counts - sort of reverting some o...tparscal18:13, 13 April 2011

Status & tagging log