Skip to content

Commit

Permalink
Drop optimise event, move start event
Browse files Browse the repository at this point in the history
Drop "optimise", the manual compaction step. We don't need to do this
as we are compacting on write as we go.

Move start. This now happens once we decide we are going to purge, as
it's more useful to show this early and have something to show while
we pull in and organise documents that need purging.

#5348
  • Loading branch information
SCdF authored and garethbowen committed Feb 14, 2019
1 parent d2b930e commit 88896e5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 19 deletions.
16 changes: 3 additions & 13 deletions webapp/src/js/bootstrapper/purger.js
Expand Up @@ -35,14 +35,11 @@ const hash = str => {
* purge(DB)
* .on('start', ...)
* .on('progress, ...)
* .on('optimise', ...)
* .on('done', ...);
*
* start: fired once we've worked out what to purge, callback is passed 'totalContacts'
* start: fired once we've decided that we are going to purge this session
* progress: fired after every contact has had purge run over it, callback is passed
* an object containing progress information and current purge count
* optimise: fired just before compaction is run. We cannot introspect this effort
* and it may take some time to complete
* done: fired once everything is complete, callback is passed the total purge count
*/
module.exports = function(DB, userCtx, initialReplication) {
Expand Down Expand Up @@ -238,7 +235,6 @@ module.exports = function(DB, userCtx, initialReplication) {
const total = sets.length;
let processed = 0;

publish('start', {totalContacts: total});
return sets.reduce(
(p, set) => p
.then(purgeCount => purgeContact(fn, userCtx, set, purgeCount))
Expand Down Expand Up @@ -266,6 +262,8 @@ module.exports = function(DB, userCtx, initialReplication) {
return urgeToPurge(config)
.then(shouldPurge => {
if (shouldPurge) {
publish('start');

return purge(config.fn, userCtx)
.then(purgeCount => {
console.log(`Purge complete, purged ${purgeCount} documents`);
Expand Down Expand Up @@ -293,14 +291,6 @@ module.exports = function(DB, userCtx, initialReplication) {

const p = Promise.resolve()
.then(() => begin(userCtx))
.then(count => {
if (count) {
publish('optimise');
return DB.compact().then(() => count);
} else {
return count;
}
})
.then(count => publish('done', {totalPurged: count}));

p.on = (type, callback) => {
Expand Down
6 changes: 0 additions & 6 deletions webapp/src/js/bootstrapper/translator.js
Expand Up @@ -8,7 +8,6 @@ var TRANSLATIONS = {
LOAD_APP: 'Loading app…',
PURGE_INIT: 'Checking data…',
PURGE_INFO: ({ count, percent }) => `Cleaned ${count} documents (${percent}% complete)…`,
PURGE_AFTER: 'Optimizing…',
LOAD_RULES: 'Loading rules…',
STARTING_APP: 'Starting app…',
DOWNLOAD_APP: 'Downloading app…',
Expand All @@ -20,7 +19,6 @@ var TRANSLATIONS = {
LOAD_APP: 'Cargando aplicación…',
PURGE_INIT: 'Verificación de datos…',
PURGE_INFO: ({ count, percent }) => `Limpiado ${count} documentos (${percent}% completo)…`,
PURGE_AFTER: 'Mejoramiento…',
LOAD_RULES: 'Cargando reglas…',
STARTING_APP: 'Aplicación iniciando…',
DOWNLOAD_APP: 'Descargando aplicación…',
Expand All @@ -32,7 +30,6 @@ var TRANSLATIONS = {
LOAD_APP: 'Inapakia programu…',
PURGE_INIT: 'Kuangalia takwimu…',
PURGE_INFO: ({ count, percent }) => `Imesafisha hati ${count} (Asilimia ${percent} imekamilika)…`,
PURGE_AFTER: 'Kuboresha…',
LOAD_RULES: 'Inapakia kanuni…',
STARTING_APP: 'Programu yaanza…',
DOWNLOAD_APP: 'Kupakua programu…',
Expand All @@ -48,7 +45,6 @@ var TRANSLATIONS = {
LOAD_APP: 'एप लोड गर्दै…',
PURGE_INIT: 'डाटा जाँच गर्दै…',
PURGE_INFO: ({ count, percent }) => `${count} वटा डकुमेन्ट सफा गरीयो (${percent}% कार्य सम्पन्न)…`,
PURGE_AFTER: 'अनुकूलन गर्दै…',
LOAD_RULES: 'नियमहरू लोड गर्दै…',
STARTING_APP: 'एप सुरु हुँदैछ…',
DOWNLOAD_APP: 'ऐप डाउनलोड गर्दै…',
Expand All @@ -60,7 +56,6 @@ var TRANSLATIONS = {
LOAD_APP: 'Chargement de l’application…',
PURGE_INIT: 'Vérification des données…',
PURGE_INFO: ({ count, percent }) => `${count} document(s) nettoyé(s) [${percent}% terminé(s)]…`,
PURGE_AFTER: 'Optimisation en cours…',
LOAD_RULES: 'Chargement des paramètres…',
STARTING_APP: 'App de démarrage…',
DOWNLOAD_APP: 'Téléchargement de l\'app en cours…',
Expand All @@ -72,7 +67,6 @@ var TRANSLATIONS = {
LOAD_APP: 'एप्लीकेशन लोड हो रही है…',
PURGE_INIT: 'डेटा की जाँच…',
PURGE_INFO: ({ count, percent }) => `${count} दस्तावेज साफ किए (${percent}% पूर्ण)…`,
PURGE_AFTER: 'ऑप्टिमाइज़िंग…',
LOAD_RULES: 'नियम लोड हो रहें हैं…',
STARTING_APP: 'ऐप शुरी की जा रही है…',
DOWNLOAD_APP: 'एप डाउनलोड हो रही है…',
Expand Down

0 comments on commit 88896e5

Please sign in to comment.