https://www.mediawiki.org/wiki/Special:Code/MediaWiki/110086

Revision: 110086
Author:   gregchiasson
Date:     2012-01-26 21:57:20 +0000 (Thu, 26 Jan 2012)
Log Message:
-----------
AFT5 - SQL statements to rebuild the rollup tables using only bucket 1, and a 
fix to prevent loading errors if a record with no timestamp comes up (which 
should be impossible anyway, but has happened on dev, and should be handled 
either way, instead of breaking the page).

Modified Paths:
--------------
    trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php
    trunk/extensions/ArticleFeedbackv5/sql/alter.sql

Modified: 
trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php
===================================================================
--- trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php 
2012-01-26 21:15:11 UTC (rev 110085)
+++ trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php 
2012-01-26 21:57:20 UTC (rev 110086)
@@ -302,8 +302,9 @@
                                ( $now - $timestamp ), 'avoidseconds'
                        );
                        $date = wfMessage( 'articleFeedbackv5-comment-ago', 
$time )->escaped();
+               } elseif( $timestamp ) {
+                       $date = $wgLang->timeanddate($record[0]->af_created  );
                } else {
-                       $date = $wgLang->timeanddate($record[0]->af_created  );
                }
 
                $details = Html::openElement( 'div', array(

Modified: trunk/extensions/ArticleFeedbackv5/sql/alter.sql
===================================================================
--- trunk/extensions/ArticleFeedbackv5/sql/alter.sql    2012-01-26 21:15:11 UTC 
(rev 110085)
+++ trunk/extensions/ArticleFeedbackv5/sql/alter.sql    2012-01-26 21:57:20 UTC 
(rev 110086)
@@ -66,6 +66,8 @@
 ALTER TABLE aft_article_feedback ADD COLUMN af_unhelpful_count integer 
unsigned NOT NULL DEFAULT 0;
 
 -- added  or updated 1/24 (greg)
+ALTER TABLE aft_article_feedback ADD COLUMN af_needs_oversight boolean NOT 
NULL DEFAULT FALSE;
+
 DELETE FROM aft_article_filter_count;
 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 CONVERT(af_helpful_count, SIGNED) - 
CONVERT(af_unhelpful_count, SIGNED) > 0 GROUP BY af_page_id;
 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_abuse_count > 0 GROUP BY af_page_id;
@@ -76,4 +78,30 @@
 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_delete_count > 0 GROUP BY af_page_id;
 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 CONVERT(af_helpful_count, SIGNED) - 
CONVERT(af_unhelpful_count, SIGNED) < 0 GROUP BY af_page_id;
 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_needs_oversight IS TRUE GROUP BY af_page_id;
-ALTER TABLE aft_article_feedback ADD COLUMN af_needs_oversight boolean NOT 
NULL DEFAULT FALSE;
+
+-- added 1/26 (greg) - obviates much of the above from 1/24.
+DELETE FROM aft_article_filter_count;
+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;
+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;
+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_hide_count > 0 GROUP BY 
af_page_id;
+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_hide_count = 0 GROUP BY 
af_page_id;
+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;
+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;
+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_delete_count > 0 GROUP BY 
af_page_id;
+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;
+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;
+
+-- Note that this ignores the select rollups, since bucket 1 doesn't have any 
+-- selects in it. Those tables can be truncated, or possibly dropped entirely,
+-- if bucket 1 remains the only bucket. Holding off on that decision for now.
+DELETE FROM aft_article_feedback_ratings_rollup;
+DELETE FROM aft_article_revision_feedback_ratings_rollup;
+INSERT INTO aft_article_revision_feedback_ratings_rollup (afrr_page_id, 
afrr_revision_id, afrr_field_id, afrr_total, afrr_count)  
+SELECT af_page_id, af_revision_id, aa_field_id, SUM(aa_response_boolean), 
COUNT(aa_response_boolean) 
+FROM aft_article_feedback, aft_article_answer
+WHERE af_bucket_id = 1 AND af_id = aa_feedback_id AND aa_response_boolean IS 
NOT NULL
+GROUP BY af_page_id, af_revision_id;
+INSERT INTO aft_article_feedback_ratings_rollup (arr_page_id, arr_field_id, 
arr_total, arr_count)
+SELECT afrr_page_id, afrr_field_id, SUM(afrr_total), SUM(afrr_count)
+FROM aft_article_revision_feedback_ratings_rollup
+GROUP BY afrr_page_id;


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to