EBernhardson has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/335160 )
Change subject: Add a query parameter to force users into search satisfaction ...................................................................... Add a query parameter to force users into search satisfaction When testing, along with demoing, changes to the satisfaction schema prior to deployment we often need some way to put users into the test. It can be done with some hackery in the js console, but this makes things much more explicit. Ideally we would also not ship events, to allow this to be used in production as well, but we need to ship the events so the debug handling in EventLogging (eventlogging-display-web) can generate notifications showing logging as it happens. Change-Id: I76b981d65ae819a03a6bad5d8980153757736cec --- M modules/ext.wikimediaEvents.searchSatisfaction.js 1 file changed, 45 insertions(+), 28 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikimediaEvents refs/changes/60/335160/1 diff --git a/modules/ext.wikimediaEvents.searchSatisfaction.js b/modules/ext.wikimediaEvents.searchSatisfaction.js index 92a6d9c..ae4b7b2 100644 --- a/modules/ext.wikimediaEvents.searchSatisfaction.js +++ b/modules/ext.wikimediaEvents.searchSatisfaction.js @@ -113,17 +113,19 @@ function initialize( session ) { var sessionId = session.get( 'sessionId' ), + // Allow for a query parameter that puts a user into the test, optionally with an explicit bucket chosen + forceIntoTest = uri.query.forceSearchSatisfaction !== undefined, + forceIntoBucket = ( forceIntoTest && uri.query.forceSearchSatisfaction !== null ) ? uri.query.forceSearchSatisfaction : false, + // List of valid sub-test buckets + validBuckets = [ + 'bm25:control', + 'bm25:inclinks_pv' + ], + // Sampling to use when choosing which users should participate in test sampleSize = ( function () { var dbName = mw.config.get( 'wgDBname' ), - subTests = { - thwiki: { - // 1:5 overall sessions into test - test: 5, - // 1:39 of test sessions reserved for dashboard - // 38:39 sessions split evenly between test buckets - subTest: 39 - } - }; + // Not currently used, but may be used in the future + subTests = {}; if ( subTests[ dbName ] ) { return subTests[ dbName ]; @@ -167,28 +169,43 @@ return buckets[ Math.floor( parsed / step ) ]; }; - if ( sessionId === 'rejected' ) { - // User was previously rejected - return; - } - // If a sessionId exists the user was previously accepted into the test - if ( !sessionId ) { - if ( !oneIn( sampleSize.test ) ) { - // user was not chosen in a sampling of search results - session.set( 'sessionId', 'rejected' ); + if ( forceIntoTest ) { + if ( sessionId === 'rejected' || !sessionId ) { + // No valid session id set, create one + session.set( 'sessionId', randomToken() ); + } + if ( forceIntoBucket !== false && $.inArray( forceIntoBucket, validBuckets ) === -1 ) { + // Bucket was chosen but it's not a currently valid bucket + forceIntoBucket = false; + } + if ( forceIntoBucket !== false ) { + // Query string requested a specific bucket + session.set( 'subTest', forceIntoBucket ); + } else if ( !session.has( 'subTest' ) && validBuckets.length > 0 ) { + // Always place forced users into a bucket if one is available + session.set( 'subTest', chooseBucket( validBuckets ) ); + } + } else { + if ( sessionId === 'rejected' ) { + // User was previously rejected return; } - // User was chosen to participate in the test and does not yet - // have a search session id, generate one. - if ( !session.set( 'sessionId', randomToken() ) ) { - return; - } + // If a sessionId exists the user was previously accepted into the test + if ( !sessionId ) { + if ( !oneIn( sampleSize.test ) ) { + // user was not chosen in a sampling of search results + session.set( 'sessionId', 'rejected' ); + return; + } + // User was chosen to participate in the test and does not yet + // have a search session id, generate one. + if ( !session.set( 'sessionId', randomToken() ) ) { + return; + } - if ( sampleSize.subTest !== null && !oneIn( sampleSize.subTest ) ) { - session.set( 'subTest', chooseBucket( [ - 'bm25:control', - 'bm25:inclinks_pv' - ] ) ); + if ( sampleSize.subTest !== null && !oneIn( sampleSize.subTest ) ) { + session.set( 'subTest', chooseBucket( validBuckets ) ); + } } } -- To view, visit https://gerrit.wikimedia.org/r/335160 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I76b981d65ae819a03a6bad5d8980153757736cec Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikimediaEvents Gerrit-Branch: master Gerrit-Owner: EBernhardson <ebernhard...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits