[MediaWiki-commits] [Gerrit] mediawiki...WikimediaEvents[wmf/1.30.0-wmf.17]: Only show human relevance survey to a browser every 2 days

2017-09-08 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/376861 )

Change subject: Only show human relevance survey to a browser every 2 days
..


Only show human relevance survey to a browser every 2 days

Some users, especially if they visit a page with a low sampling
rate multiple times, will see the survey more often than expected
and potentially be annoyed.

Setup a timeout such that there will be a 2 day delay between
occurances of a user being shown the survey.

Change-Id: Ic3da1c68b09b7461db10d11e2cbd9bed3bca9143
(cherry picked from commit 198c8a968114e45ea01902bf84d7dd69d00f7b76)
---
M modules/ext.wikimediaEvents.humanSearchRelevance.js
1 file changed, 15 insertions(+), 4 deletions(-)

Approvals:
  EBernhardson: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/ext.wikimediaEvents.humanSearchRelevance.js 
b/modules/ext.wikimediaEvents.humanSearchRelevance.js
index 5ee8fb2..47d7591 100644
--- a/modules/ext.wikimediaEvents.humanSearchRelevance.js
+++ b/modules/ext.wikimediaEvents.humanSearchRelevance.js
@@ -24,10 +24,13 @@
return;
}
 
-   // This value is coded into the page output and cached in varnish. That
-   // means any changes to sampling rates or pages chosen will take up to a
-   // week to propogate into the wild.
-   var config = mw.config.get( 'wgWMESearchRelevancePages' );
+   // The config value is coded into the page output and cached in varnish.
+   // That means any changes to sampling rates or pages chosen will take 
up to
+   // a week to propogate into the wild.
+   var timeout,
+   config = mw.config.get( 'wgWMESearchRelevancePages' ),
+   timeoutKey = 'wme-humrel-timeout',
+   now = new Date().getTime();
 
// bad configuration
if ( !config.hasOwnProperty( 'sampleRate' ) || !config.hasOwnProperty( 
'queries' ) ) {
@@ -39,6 +42,14 @@
return;
}
 
+   timeout = mw.storage.get( timeoutKey );
+   if ( timeout && timeout > now ) {
+   // User has seen the survey recently
+   return;
+   }
+   // Don't show the survey to same browser for 2 days, to prevent 
annoying users
+   mw.storage.set( timeoutKey, now + 2 * 86400 );
+
function askQuestion() {
mw.loader.using( [
'oojs-ui-core',

-- 
To view, visit https://gerrit.wikimedia.org/r/376861
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic3da1c68b09b7461db10d11e2cbd9bed3bca9143
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikimediaEvents
Gerrit-Branch: wmf/1.30.0-wmf.17
Gerrit-Owner: EBernhardson 
Gerrit-Reviewer: EBernhardson 
Gerrit-Reviewer: jenkins-bot <>

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki...WikimediaEvents[wmf/1.30.0-wmf.17]: Only show human relevance survey to a browser every 2 days

2017-09-08 Thread EBernhardson (Code Review)
EBernhardson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/376861 )

Change subject: Only show human relevance survey to a browser every 2 days
..

Only show human relevance survey to a browser every 2 days

Some users, especially if they visit a page with a low sampling
rate multiple times, will see the survey more often than expected
and potentially be annoyed.

Setup a timeout such that there will be a 2 day delay between
occurances of a user being shown the survey.

Change-Id: Ic3da1c68b09b7461db10d11e2cbd9bed3bca9143
(cherry picked from commit 198c8a968114e45ea01902bf84d7dd69d00f7b76)
---
M modules/ext.wikimediaEvents.humanSearchRelevance.js
1 file changed, 15 insertions(+), 4 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikimediaEvents 
refs/changes/61/376861/1

diff --git a/modules/ext.wikimediaEvents.humanSearchRelevance.js 
b/modules/ext.wikimediaEvents.humanSearchRelevance.js
index 5ee8fb2..47d7591 100644
--- a/modules/ext.wikimediaEvents.humanSearchRelevance.js
+++ b/modules/ext.wikimediaEvents.humanSearchRelevance.js
@@ -24,10 +24,13 @@
return;
}
 
-   // This value is coded into the page output and cached in varnish. That
-   // means any changes to sampling rates or pages chosen will take up to a
-   // week to propogate into the wild.
-   var config = mw.config.get( 'wgWMESearchRelevancePages' );
+   // The config value is coded into the page output and cached in varnish.
+   // That means any changes to sampling rates or pages chosen will take 
up to
+   // a week to propogate into the wild.
+   var timeout,
+   config = mw.config.get( 'wgWMESearchRelevancePages' ),
+   timeoutKey = 'wme-humrel-timeout',
+   now = new Date().getTime();
 
// bad configuration
if ( !config.hasOwnProperty( 'sampleRate' ) || !config.hasOwnProperty( 
'queries' ) ) {
@@ -39,6 +42,14 @@
return;
}
 
+   timeout = mw.storage.get( timeoutKey );
+   if ( timeout && timeout > now ) {
+   // User has seen the survey recently
+   return;
+   }
+   // Don't show the survey to same browser for 2 days, to prevent 
annoying users
+   mw.storage.set( timeoutKey, now + 2 * 86400 );
+
function askQuestion() {
mw.loader.using( [
'oojs-ui-core',

-- 
To view, visit https://gerrit.wikimedia.org/r/376861
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic3da1c68b09b7461db10d11e2cbd9bed3bca9143
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikimediaEvents
Gerrit-Branch: wmf/1.30.0-wmf.17
Gerrit-Owner: EBernhardson 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits