r111512 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111511‎ | r111512 | r111513 >
Date:23:59, 14 February 2012
Author:gregchiasson
Status:resolved (Comments)
Tags:
Comment:
AFT5 - somewhat untested changes to filter counts, that should fix some of the issues with counts getting out of sync with reality.
Modified paths:
  • /trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5Utils.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/sql/filter_count.sql (added) (history)

Diff [purge]

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
112 + native
Index: trunk/extensions/ArticleFeedbackv5/api/ApiFlagFeedbackArticleFeedbackv5.php
@@ -65,17 +65,16 @@
6666 } else {
6767 $update[] = "$field = FALSE";
6868 }
69 -
7069 // Increment or decrement whichever flag is being set.
7170 $countDirection = $direction == 'increase' ? 'increment' : 'decrement';
7271 $counts[$countDirection][] = $count;
7372 // If this is hiding/deleting, decrement the visible count.
74 - if( ( $count == 'hide' || $count == 'deleted' )
 73+ if( ( $flag == 'hide' || $flag == 'delete' )
7574 && $direction == 'increase' ) {
7675 $counts['decrement'][] = 'visible';
7776 }
7877 // If this is unhiding/undeleting, increment the visible count.
79 - if( ( $count == 'hide' || $count == 'deleted' )
 78+ if( ( $flag == 'hide' || $flag == 'delete' )
8079 && $direction == 'decrease' ) {
8180 $counts['increment'][] = 'visible';
8281 }
@@ -108,11 +107,21 @@
109108 if( $flag == 'abuse' && $direction == 'increase'
110109 && $record->af_abuse_count == 0 ) {
111110 $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+ }
112116 }
113117 // Removing the last abuse flag: abusive--
114118 if( $flag == 'abuse' && $direction == 'decrease'
115119 && $record->af_abuse_count == 1 ) {
116120 $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+ }
117126 }
118127
119128 // note that a net helpfulness of 0 is neither helpful nor unhelpful
@@ -124,12 +133,12 @@
125134 ) {
126135 // net was -1: no longer unhelpful
127136 if( $netHelpfulness == -1 ) {
128 - $counts['decrement'] = 'unhelpful';
 137+ $counts['decrement'][] = 'unhelpful';
129138 }
130139
131140 // net was 0: now helpful
132 - if( $netHelpfulness == -1 ) {
133 - $counts['increment'] = 'helpful';
 141+ if( $netHelpfulness == 0 ) {
 142+ $counts['increment'][] = 'helpful';
134143 }
135144 }
136145
@@ -139,12 +148,12 @@
140149 ) {
141150 // net was 1: no longer helpful
142151 if( $netHelpfulness == 1 ) {
143 - $counts['decrement'] = 'helpful';
 152+ $counts['decrement'][] = 'helpful';
144153 }
145154
146155 // net was 0: now unhelpful
147156 if( $netHelpfulness == 0 ) {
148 - $counts['increment'] = 'unhelpful';
 157+ $counts['increment'][] = 'unhelpful';
149158 }
150159 }
151160 } else {
@@ -176,6 +185,7 @@
177186
178187 ApiArticleFeedbackv5Utils::logActivity( $activity , $pageId, $feedbackId, $notes );
179188
 189+>>>>>>> .r111511
180190 // Update the filter count rollups.
181191 ApiArticleFeedbackv5Utils::incrementFilterCounts( $pageId, $counts['increment'] );
182192 ApiArticleFeedbackv5Utils::decrementFilterCounts( $pageId, $counts['decrement'] );
@@ -237,6 +247,7 @@
238248 $results['abuse-hidden'] = 1;
239249 }
240250
 251+ // Hide the row if the abuse count is above our threshhold
241252 $dbw->update(
242253 'aft_article_feedback',
243254 array( 'af_is_hidden = TRUE' ),
Index: trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5Utils.php
@@ -174,13 +174,20 @@
175175
176176 public function updateFilterCounts( $pageId, $filters, $decrement ) {
177177 // 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+ }
180186
181187 $dbw = wfGetDB( DB_MASTER );
182188 $dbw->begin();
183189
184190 foreach ( $filters as $filter ) {
 191+error_log("have filter $filter for page $pageId");
185192 $rows[] = array(
186193 'afc_page_id' => $pageId,
187194 'afc_filter_name' => $filter,
@@ -198,9 +205,11 @@
199206 );
200207
201208 $value = $decrement ? 'afc_filter_count - 1' : 'afc_filter_count + 1';
 209+error_log("new value is $value");
202210
203211 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.
205214 $dbw->update(
206215 'aft_article_filter_count',
207216 array( "afc_filter_count = $value" ),

Comments

#Comment by Catrope (talk | contribs)   19:14, 1 March 2012

Conflict marker and error_log() calls were removed in a later revision.

Status & tagging log