Index: trunk/extensions/ArticleFeedback/api/ApiArticleFeedback.php |
— | — | @@ -93,13 +93,13 @@ |
94 | 94 | |
95 | 95 | // Try to insert a new "totals" row for this page,rev,rating set |
96 | 96 | $dbw->insert( |
97 | | - 'article_feedback_pages', |
| 97 | + 'article_feedback_revisions', |
98 | 98 | 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, |
104 | 104 | ), |
105 | 105 | __METHOD__, |
106 | 106 | array( 'IGNORE' ) |
— | — | @@ -113,30 +113,30 @@ |
114 | 114 | if ( $lastRating ) { |
115 | 115 | // Deduct the previous rating values from the previous "totals" row |
116 | 116 | $dbw->update( |
117 | | - 'article_feedback_pages', |
| 117 | + 'article_feedback_revisions', |
118 | 118 | 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', |
121 | 121 | ), |
122 | 122 | 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 |
126 | 126 | ), |
127 | 127 | __METHOD__ |
128 | 128 | ); |
129 | 129 | } |
130 | 130 | // Add this rating's values to the new "totals" row |
131 | 131 | $dbw->update( |
132 | | - 'article_feedback_pages', |
| 132 | + 'article_feedback_revisions', |
133 | 133 | array( |
134 | | - 'aap_total' => $thisRating, |
135 | | - 'aap_count' => 1, |
| 134 | + 'afr_total' => $thisRating, |
| 135 | + 'afr_count' => 1, |
136 | 136 | ), |
137 | 137 | 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, |
141 | 141 | ), |
142 | 142 | __METHOD__ |
143 | 143 | ); |
— | — | @@ -162,15 +162,15 @@ |
163 | 163 | } |
164 | 164 | // Apply the difference between the previous and new ratings to the current "totals" row |
165 | 165 | $dbw->update( |
166 | | - 'article_feedback_pages', |
| 166 | + 'article_feedback_revisions', |
167 | 167 | 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, |
170 | 170 | ), |
171 | 171 | 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, |
175 | 175 | ), |
176 | 176 | __METHOD__ |
177 | 177 | ); |
Index: trunk/extensions/ArticleFeedback/api/ApiQueryArticleFeedback.php |
— | — | @@ -11,24 +11,24 @@ |
12 | 12 | $result = $this->getResult(); |
13 | 13 | $revisionLimit = $this->getRevisionLimit( $params['pageid'] ); |
14 | 14 | |
15 | | - $this->addTables( array( 'article_feedback_pages', 'article_feedback_ratings' ) ); |
| 15 | + $this->addTables( array( 'article_feedback_revisions', 'article_feedback_ratings' ) ); |
16 | 16 | $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', |
21 | 21 | 'aar_rating', |
22 | 22 | ) ); |
23 | 23 | $this->addJoinConds( array( |
24 | 24 | '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, |
27 | 27 | ) |
28 | 28 | ), |
29 | 29 | ) ); |
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' ); |
33 | 33 | $this->addOption( 'LIMIT', count( $wgArticleFeedbackRatings ) ); |
34 | 34 | |
35 | 35 | // Rating counts and totals |
— | — | @@ -37,18 +37,18 @@ |
38 | 38 | $historicCounts = $this->getHistoricCounts( $params ); |
39 | 39 | foreach ( $res as $i => $row ) { |
40 | 40 | if ( !isset( $ratings[$params['pageid']]['revid'] ) ) { |
41 | | - $ratings[$params['pageid']]['revid'] = (int) $row->aap_revision; |
| 41 | + $ratings[$params['pageid']]['revid'] = (int) $row->afr_revision; |
42 | 42 | } |
43 | 43 | if ( !isset( $ratings[$params['pageid']]['ratings'] ) ) { |
44 | 44 | $ratings[$params['pageid']]['ratings'] = array(); |
45 | 45 | } |
46 | 46 | $ratings[$params['pageid']]['ratings'][] = array( |
47 | | - 'ratingid' => (int) $row->aap_rating_id, |
| 47 | + 'ratingid' => (int) $row->afr_rating_id, |
48 | 48 | '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 |
53 | 53 | ); |
54 | 54 | } |
55 | 55 | |
— | — | @@ -90,8 +90,8 @@ |
91 | 91 | 'ratingdesc' => $userRating['text'], |
92 | 92 | 'total' => 0, |
93 | 93 | '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, |
96 | 96 | 'userrating' => (int) $userRating['value'], |
97 | 97 | ); |
98 | 98 | } |
— | — | @@ -117,21 +117,21 @@ |
118 | 118 | global $wgArticleFeedbackRatings; |
119 | 119 | |
120 | 120 | $res = $this->getDB()->select( |
121 | | - 'article_feedback_pages', |
| 121 | + 'article_feedback_revisions', |
122 | 122 | array( |
123 | | - 'aap_rating_id', |
124 | | - 'SUM(aap_count) as count', |
| 123 | + 'afr_rating_id', |
| 124 | + 'SUM(afr_count) as count', |
125 | 125 | ), |
126 | 126 | array( |
127 | | - 'aap_page_id' => $params['pageid'], |
128 | | - 'aap_rating_id' => $wgArticleFeedbackRatings, |
| 127 | + 'afr_page_id' => $params['pageid'], |
| 128 | + 'afr_rating_id' => $wgArticleFeedbackRatings, |
129 | 129 | ), |
130 | 130 | __METHOD__, |
131 | | - array( 'GROUP BY' => 'aap_rating_id') |
| 131 | + array( 'GROUP BY' => 'afr_rating_id') |
132 | 132 | ); |
133 | 133 | $counts = array(); |
134 | 134 | foreach ( $res as $row ) { |
135 | | - $counts[$row->aap_rating_id] = $row->count; |
| 135 | + $counts[$row->afr_rating_id] = $row->count; |
136 | 136 | } |
137 | 137 | return $counts; |
138 | 138 | } |