Index: trunk/extensions/ArticleFeedbackv5/sql/filter_count.sql |
— | — | @@ -0,0 +1,10 @@ |
| 2 | +DELETE FROM aft_article_filter_count; |
| 3 | +INSERT INTO aft_article_filter_count(afc_page_id, afc_filter_name, afc_filter_count) SELECT af_page_id, 'helpful', COUNT(*) FROM aft_article_feedback WHERE af_bucket_id = 1 AND CONVERT(af_helpful_count, SIGNED) - CONVERT(af_unhelpful_count, SIGNED) > 0 GROUP BY af_page_id; |
| 4 | +INSERT INTO aft_article_filter_count(afc_page_id, afc_filter_name, afc_filter_count) SELECT af_page_id, 'abusive', COUNT(*) FROM aft_article_feedback WHERE af_bucket_id = 1 AND af_abuse_count > 0 GROUP BY af_page_id; |
| 5 | +INSERT INTO aft_article_filter_count(afc_page_id, afc_filter_name, afc_filter_count) SELECT af_page_id, 'all', COUNT(*) FROM aft_article_feedback WHERE af_bucket_id = 1 GROUP BY af_page_id; |
| 6 | +INSERT INTO aft_article_filter_count(afc_page_id, afc_filter_name, afc_filter_count) SELECT af_page_id, 'comment', COUNT(*) FROM aft_article_feedback, aft_article_answer WHERE af_bucket_id = 1 AND af_id = aa_feedback_id AND aa_response_text IS NOT NULL GROUP BY af_page_id; |
| 7 | +INSERT INTO aft_article_filter_count(afc_page_id, afc_filter_name, afc_filter_count) SELECT af_page_id, 'unhelpful', COUNT(*) FROM aft_article_feedback WHERE af_bucket_id = 1 AND CONVERT(af_helpful_count, SIGNED) - CONVERT(af_unhelpful_count, SIGNED) < 0 GROUP BY af_page_id; |
| 8 | +INSERT INTO aft_article_filter_count(afc_page_id, afc_filter_name, afc_filter_count) SELECT af_page_id, 'needsoversight', COUNT(*) FROM aft_article_feedback WHERE af_bucket_id = 1 AND af_needs_oversight IS TRUE GROUP BY af_page_id; |
| 9 | +INSERT INTO aft_article_filter_count(afc_page_id, afc_filter_name, afc_filter_count) SELECT af_page_id, 'invisible', COUNT(*) FROM aft_article_feedback WHERE af_bucket_id = 1 AND af_is_hidden IS TRUE GROUP BY af_page_id; |
| 10 | +INSERT INTO aft_article_filter_count(afc_page_id, afc_filter_name, afc_filter_count) SELECT af_page_id, 'visible', COUNT(*) FROM aft_article_feedback WHERE af_bucket_id = 1 AND af_is_hidden IS FALSE AND af_is_deleted IS FALSE GROUP BY af_page_id; |
| 11 | +INSERT INTO aft_article_filter_count(afc_page_id, afc_filter_name, afc_filter_count) SELECT af_page_id, 'deleted', COUNT(*) FROM aft_article_feedback WHERE af_bucket_id = 1 AND af_is_deleted IS TRUE GROUP BY af_page_id; |
Property changes on: trunk/extensions/ArticleFeedbackv5/sql/filter_count.sql |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 12 | + native |
Index: trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php |
— | — | @@ -65,17 +65,16 @@ |
66 | 66 | } else { |
67 | 67 | $update[] = "$field = FALSE"; |
68 | 68 | } |
69 | | - |
70 | 69 | // Increment or decrement whichever flag is being set. |
71 | 70 | $countDirection = $direction == 'increase' ? 'increment' : 'decrement'; |
72 | 71 | $counts[$countDirection][] = $count; |
73 | 72 | // If this is hiding/deleting, decrement the visible count. |
74 | | - if( ( $count == 'hide' || $count == 'deleted' ) |
| 73 | + if( ( $flag == 'hide' || $flag == 'delete' ) |
75 | 74 | && $direction == 'increase' ) { |
76 | 75 | $counts['decrement'][] = 'visible'; |
77 | 76 | } |
78 | 77 | // If this is unhiding/undeleting, increment the visible count. |
79 | | - if( ( $count == 'hide' || $count == 'deleted' ) |
| 78 | + if( ( $flag == 'hide' || $flag == 'delete' ) |
80 | 79 | && $direction == 'decrease' ) { |
81 | 80 | $counts['increment'][] = 'visible'; |
82 | 81 | } |
— | — | @@ -108,11 +107,21 @@ |
109 | 108 | if( $flag == 'abuse' && $direction == 'increase' |
110 | 109 | && $record->af_abuse_count == 0 ) { |
111 | 110 | $counts['increment'][] = 'abusive'; |
| 111 | + // Auto-hide after 5 abuse flags. |
| 112 | + if( $record->af_abuse_count > 4 ) { |
| 113 | + $counts['increment'][] = 'invisible'; |
| 114 | + $counts['decrement'][] = 'visible'; |
| 115 | + } |
112 | 116 | } |
113 | 117 | // Removing the last abuse flag: abusive-- |
114 | 118 | if( $flag == 'abuse' && $direction == 'decrease' |
115 | 119 | && $record->af_abuse_count == 1 ) { |
116 | 120 | $counts['decrement'][] = 'abusive'; |
| 121 | + // Un-hide if we don't have 5 flags anymore |
| 122 | + if( $record->af_abuse_count == 5 ) { |
| 123 | + $counts['increment'][] = 'visible'; |
| 124 | + $counts['decrement'][] = 'invisible'; |
| 125 | + } |
117 | 126 | } |
118 | 127 | |
119 | 128 | // note that a net helpfulness of 0 is neither helpful nor unhelpful |
— | — | @@ -124,12 +133,12 @@ |
125 | 134 | ) { |
126 | 135 | // net was -1: no longer unhelpful |
127 | 136 | if( $netHelpfulness == -1 ) { |
128 | | - $counts['decrement'] = 'unhelpful'; |
| 137 | + $counts['decrement'][] = 'unhelpful'; |
129 | 138 | } |
130 | 139 | |
131 | 140 | // net was 0: now helpful |
132 | | - if( $netHelpfulness == -1 ) { |
133 | | - $counts['increment'] = 'helpful'; |
| 141 | + if( $netHelpfulness == 0 ) { |
| 142 | + $counts['increment'][] = 'helpful'; |
134 | 143 | } |
135 | 144 | } |
136 | 145 | |
— | — | @@ -139,12 +148,12 @@ |
140 | 149 | ) { |
141 | 150 | // net was 1: no longer helpful |
142 | 151 | if( $netHelpfulness == 1 ) { |
143 | | - $counts['decrement'] = 'helpful'; |
| 152 | + $counts['decrement'][] = 'helpful'; |
144 | 153 | } |
145 | 154 | |
146 | 155 | // net was 0: now unhelpful |
147 | 156 | if( $netHelpfulness == 0 ) { |
148 | | - $counts['increment'] = 'unhelpful'; |
| 157 | + $counts['increment'][] = 'unhelpful'; |
149 | 158 | } |
150 | 159 | } |
151 | 160 | } else { |
— | — | @@ -176,6 +185,7 @@ |
177 | 186 | |
178 | 187 | ApiArticleFeedbackv5Utils::logActivity( $activity , $pageId, $feedbackId, $notes ); |
179 | 188 | |
| 189 | +>>>>>>> .r111511 |
180 | 190 | // Update the filter count rollups. |
181 | 191 | ApiArticleFeedbackv5Utils::incrementFilterCounts( $pageId, $counts['increment'] ); |
182 | 192 | ApiArticleFeedbackv5Utils::decrementFilterCounts( $pageId, $counts['decrement'] ); |
— | — | @@ -237,6 +247,7 @@ |
238 | 248 | $results['abuse-hidden'] = 1; |
239 | 249 | } |
240 | 250 | |
| 251 | + // Hide the row if the abuse count is above our threshhold |
241 | 252 | $dbw->update( |
242 | 253 | 'aft_article_feedback', |
243 | 254 | array( 'af_is_hidden = TRUE' ), |
Index: trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5Utils.php |
— | — | @@ -174,13 +174,20 @@ |
175 | 175 | |
176 | 176 | public function updateFilterCounts( $pageId, $filters, $decrement ) { |
177 | 177 | // Don't do anything unless we have filters to process. |
178 | | - if( !$filters ) { return; } |
179 | | - if( !count( $filters ) ) { return; } |
| 178 | + if( !$filters ) { |
| 179 | +error_log("no filters"); |
| 180 | + return; |
| 181 | + } |
| 182 | + if( !count( $filters ) ) { |
| 183 | +error_log("no count of filters"); |
| 184 | + return; |
| 185 | + } |
180 | 186 | |
181 | 187 | $dbw = wfGetDB( DB_MASTER ); |
182 | 188 | $dbw->begin(); |
183 | 189 | |
184 | 190 | foreach ( $filters as $filter ) { |
| 191 | +error_log("have filter $filter for page $pageId"); |
185 | 192 | $rows[] = array( |
186 | 193 | 'afc_page_id' => $pageId, |
187 | 194 | 'afc_filter_name' => $filter, |
— | — | @@ -198,9 +205,11 @@ |
199 | 206 | ); |
200 | 207 | |
201 | 208 | $value = $decrement ? 'afc_filter_count - 1' : 'afc_filter_count + 1'; |
| 209 | +error_log("new value is $value"); |
202 | 210 | |
203 | 211 | foreach ( $filters as $filter ) { |
204 | | - # Update each row with the new count. |
| 212 | +error_log("setting value for page $pageId, filter $filter"); |
| 213 | + # Update each row with the new count. |
205 | 214 | $dbw->update( |
206 | 215 | 'aft_article_filter_count', |
207 | 216 | array( "afc_filter_count = $value" ), |