Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-2159: Update frequency reduction, AB test opt-out, remove Cliqz AB test #608

Merged
merged 24 commits into from Sep 24, 2020
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d5ea47a
Reduce scheduledTasks and autoUpdatedBugDb frequencies from once an h…
wlycdgr Sep 21, 2020
544043c
Refactor autoUpdateBugDb so it always does the same thing when called…
wlycdgr Sep 21, 2020
9f2cf6c
Update autoUpdateBugDB documentation and refactor a little more to ma…
wlycdgr Sep 21, 2020
568acea
Clean up autoUpdateBugDB a bit more: Clarify docs, flatten, and move …
wlycdgr Sep 21, 2020
5c624b3
Minor comment in autoUpdateBugDb
wlycdgr Sep 21, 2020
ef45c82
Renamed autoUpdateBugDb to clarify connection to checkLibraryVersion.…
wlycdgr Sep 21, 2020
ad20931
Edit db update function names and docs to improve clarity
wlycdgr Sep 21, 2020
c761b7c
Remove Cliqz anti-tracking A/B test config code from background. Tidy…
wlycdgr Sep 21, 2020
b0a54c5
Split up and reorganize setupABTest so outside code can only call tho…
wlycdgr Sep 21, 2020
94cfe13
Merge in develop
wlycdgr Sep 22, 2020
c563a1d
Clean up OptIn a bit in preparation for adding A/B test checkbox
wlycdgr Sep 22, 2020
89d6e0f
Finish OptIn tidy-up
wlycdgr Sep 22, 2020
2572a2d
Stub out new A/B test opt-in setting. Add draft strings for it.
wlycdgr Sep 22, 2020
2d42906
Implement the enable_abtests conf setting and plug it into the checkb…
wlycdgr Sep 23, 2020
1f3a03f
Do not call setupABTests if enable_abtests is false
wlycdgr Sep 23, 2020
cba107f
Skip the call to the AB server altogether if ab tests are disabled
wlycdgr Sep 23, 2020
f369ad2
Update AB test setting tooltip copy. remove enable_abtests from unins…
wlycdgr Sep 23, 2020
a0f0f0c
Remove unused import from Metrics
wlycdgr Sep 23, 2020
fa54859
Update test snapshot
wlycdgr Sep 23, 2020
004506b
Fix typo
wlycdgr Sep 23, 2020
98644ff
Fix comment errors
wlycdgr Sep 23, 2020
9f6b99d
Remove bloom filter Cliqz test
wlycdgr Sep 24, 2020
f1b4835
remove comment
christophertino Sep 24, 2020
6d8d250
Merge branch 'develop' into GH-2159
christophertino Sep 24, 2020
File filter
Filter file types
Jump to
Jump to file
Failed to load files.

Always

Just for now

Edit db update function names and docs to improve clarity

  • Loading branch information
wlycdgr committed Sep 21, 2020
commit ad2093110cb9e19241fe47959f104ab99d72c3a0
@@ -105,12 +105,12 @@ function setCliqzModuleEnabled(module, enabled) {

/**
* Pulls down latest version.json and triggers
* updates of all db files.
* updates of all db files. FKA checkLibraryVersion.
* @memberOf Background
*
* @return {Promise} database updated data
*/
function checkLibraryVersion() {
function updateDBs() {
return new Promise(((resolve, reject) => {
const failed = { success: false, updated: false };
utils.getJson(VERSION_CHECK_URL).then((data) => {
@@ -137,34 +137,33 @@ function checkLibraryVersion() {
});
});
}).catch((err) => {
log('Error in checkLibraryVersion', err);
log('Error in updateDBs', err);
reject(failed);
});
}));
}

/**
* Call checkLibraryVersion if auto updating is enabled and enough time has passed since the last check.
* Debug log that the function was called and when.
* Call updateDBs if auto updating is enabled and enough time has passed since the last check.
* Debug log that the function was called and when. Called at browser startup and at regular intervals thereafter.
*
* @memberOf Background
*
* @param {Boolean} isAutoUpdateEnabled Whether bug db auto updating is enabled.
* @param {Number} bugsLastCheckedMsec The Unix msec timestamp to compare against to see whether to call checkLibraryVersion again.
*
* @param {Number} bugsLastCheckedMsec The Unix msec timestamp to check against to make sure it is not too soon to call updateDBs again.
*/
function checkLibraryVersionIfNeeded(isAutoUpdateEnabled, bugsLastCheckedMsec) {
function autoUpdateDBs(isAutoUpdateEnabled, bugsLastCheckedMsec) {
const date = new Date();

log('autoUpdateBugDb called', date);
log('autoUpdateDBs called', date);

if (!isAutoUpdateEnabled) return;

if (
!bugsLastCheckedMsec // the value is 0, signifying that we have never checked yet
|| date.getTime() > (Number(bugsLastCheckedMsec) + ONE_HOUR_MSEC) // guard against double fetching
) {
checkLibraryVersion();
updateDBs();
}
}

@@ -968,7 +967,7 @@ function onMessageHandler(request, sender, callback) {
return true;
}
if (name === 'update_database') {
checkLibraryVersion().then((result) => {
updateDBs().then((result) => {
callback(result);
});
return true;
@@ -1743,11 +1742,11 @@ function initializeGhosteryModules() {
setInterval(scheduledTasks, ONE_DAY_MSEC);

// Update db right away.
checkLibraryVersionIfNeeded(conf.enable_autoupdate, conf.bugs_last_checked);
autoUpdateDBs(conf.enable_autoupdate, conf.bugs_last_checked);

// Schedule it to run every hour.
setInterval(
() => checkLibraryVersionIfNeeded(conf.enable_autoupdate, conf.bugs_last_checked),
() => autoUpdateDBs(conf.enable_autoupdate, conf.bugs_last_checked),
ONE_DAY_MSEC
);

ProTip! Use n and p to navigate between commits in a pull request.