r92716 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92715‎ | r92716 | r92717 >
Date:00:06, 21 July 2011
Author:werdna
Status:deferred
Tags:
Comment:
Bucketing: Use the inbuilt mw.user.bucket() function, and bucket the trigger rather than the trigger-show-time
Modified paths:
  • /trunk/extensions/MoodBar/MoodBar.hooks.php (modified) (history)
  • /trunk/extensions/MoodBar/MoodBar.i18n.php (modified) (history)
  • /trunk/extensions/MoodBar/MoodBar.php (modified) (history)
  • /trunk/extensions/MoodBar/modules/ext.moodBar/ext.moodBar.init.js (modified) (history)
  • /trunk/extensions/MoodBar/modules/jquery.moodBar/jquery.moodBar.js (modified) (history)

Diff [purge]

Index: trunk/extensions/MoodBar/MoodBar.i18n.php
@@ -15,10 +15,11 @@
1616 $messages['en'] = array(
1717 'moodbar-desc' => 'Allows specified users to send their "mood" back to the site operator',
1818 // Portlet link
19 - 'moodbar-trigger-using' => 'Using $1...',
 19+ 'moodbar-trigger-using' => 'Editing $1...',
 20+ 'moodbar-trigger-feedback' => 'Feedback about editing',
 21+ 'moodbar-trigger-share' => 'Share your experience',
2022 'tooltip-p-moodbar-trigger-using' => '',
2123 'moodbar-intro-using' => 'Using $1 made me...',
22 - 'moodbar-trigger-feedback' => 'Feedback',
2324 'tooltip-p-moodbar-trigger-feedback' => '',
2425 // Overlay
2526 'moodbar-close' => '(close)',
Index: trunk/extensions/MoodBar/modules/jquery.moodBar/jquery.moodBar.js
@@ -28,7 +28,7 @@
2929 'editmode' : (wgAction == 'edit') ? 1 : 0,
3030 'useragent' : clientData.name + '/' + clientData.versionBase,
3131 'system' : clientData.platform,
32 - 'bucket' : mw.config.get('mbConfig').userBuckets.join(';'),
 32+ 'bucket' : mb.conf.bucketKey,
3333 'type' : params.type,
3434 'token' : mw.user.tokens.get('editToken'),
3535 'format' : 'json'
Index: trunk/extensions/MoodBar/modules/ext.moodBar/ext.moodBar.init.js
@@ -17,10 +17,20 @@
1818
1919 init: function() {
2020 var ui = mb.ui;
 21+
 22+ mb.conf.bucketKey = mw.user.bucket(
 23+ 'moodbar-trigger',
 24+ {
 25+ 'buckets' : {
 26+ 'feedback' : 80,
 27+ 'using' : 10,
 28+ 'share' : 10
 29+ },
 30+ 'version' : 1,
 31+ 'expires' : 30
 32+ }
 33+ );
2134
22 - // Bucketing (@todo)
23 - mb.conf.bucketKey = 'using';
24 -
2535 // Create portlet
2636 ui.pMoodbar = $( '<div id="p-moodbar"></div>' );
2737
Index: trunk/extensions/MoodBar/MoodBar.php
@@ -49,11 +49,16 @@
5050 'scripts' => 'ext.moodBar/ext.moodBar.init.js',
5151 'messages' => array(
5252 'moodbar-trigger-using',
 53+ 'moodbar-trigger-feedback',
 54+ 'moodbar-trigger-share',
5355 'tooltip-p-moodbar-trigger-using',
5456 'moodbar-trigger-feedback',
5557 'tooltip-p-moodbar-trigger-feedback',
5658 ),
5759 'position' => 'top',
 60+ 'dependencies' => array(
 61+ 'mediawiki.user',
 62+ ),
5863 );
5964
6065 $wgResourceModules['ext.moodBar.core'] = $mbResourceTemplate + array(
Index: trunk/extensions/MoodBar/MoodBar.hooks.php
@@ -38,22 +38,8 @@
3939 return false;
4040 }
4141
42 - $buckets = self::getUserBuckets( $user );
 42+ return ((bool)EditPageTracking::getFirstEditPage($user));
4343
44 - if ( in_array( 'moodbar-always', $buckets ) ) {
45 - return true;
46 - } elseif( in_array( 'no-moodbar', $buckets ) ) {
47 - return false;
48 - } elseif ( in_array( 'moodbar-on-submit', $buckets ) ) {
49 - // MoodBar is shown when a user has submitted an edit
50 - return ( $user->getEditCount() > 0 );
51 - } elseif ( in_array( 'moodbar-on-edit', $buckets ) &&
52 - class_exists('EditPageTracking') )
53 - {
54 - // MoodBar is shown when a user has previously loaded the edit form
55 - return ((bool)EditPageTracking::getFirstEditPage($user));
56 - }
57 -
5844 return false;
5945 }
6046
@@ -90,20 +76,9 @@
9177 */
9278 public static function getUserBuckets( $user ) {
9379 $id = $user->getID();
94 -
95 - // 60 is divisible by 2, 3, 4, 5, 6 and 10
96 - $bucketId = $id % 60;
9780 $buckets = array();
9881
99 - if ( $bucketId < 15 ) {
100 - $buckets[] = 'no-moodbar';
101 - } elseif ( $bucketId < 30 ) {
102 - $buckets[] = 'moodbar-on-edit';
103 - } elseif ( $bucketId < 45 ) {
104 - $buckets[] = 'moodbar-on-submit';
105 - } elseif ( $bucektId < 60 ) {
106 - $buckets[] = 'moodbar-always';
107 - }
 82+ // No show-time bucketing yet. This method is a stub.
10883
10984 sort($buckets);
11085 return $buckets;

Status & tagging log