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 f62e5ed commit ac09b0b
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 @@ -34,14 +34,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 @@ -248,7 +245,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 @@ -276,6 +272,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 @@ -303,14 +301,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…',
ERROR_MESSAGE: 'Loading error, please check your connection.',
Expand All @@ -19,7 +18,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…',
ERROR_MESSAGE: 'Error al cargar, por favor comprueba la conexión',
Expand All @@ -30,7 +28,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…',
ERROR_MESSAGE: 'Kuna hitilafu katika kupakia, tafadhali hakikisha uko kwenye mtandao',
TRY_AGAIN: 'Jaribu tena',
Expand All @@ -44,7 +41,6 @@ var TRANSLATIONS = {
LOAD_APP: 'एप लोड गर्दै…',
PURGE_INIT: 'डाटा जाँच गर्दै…',
PURGE_INFO: ({ count, percent }) => `${count} वटा डकुमेन्ट सफा गरीयो (${percent}% कार्य सम्पन्न)…`,
PURGE_AFTER: 'अनुकूलन गर्दै…',
LOAD_RULES: 'नियमहरू लोड गर्दै…',
STARTING_APP: 'एप सुरु हुँदैछ…',
ERROR_MESSAGE: 'लोडिंग त्रुटि, कृपया आफ्नो ईन्टरनेट कनेक्सन जाँच गर्नुहोस्',
Expand All @@ -55,7 +51,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…',
ERROR_MESSAGE: 'Erreur de chargement, veuillez vérifier votre connexion',
Expand All @@ -66,7 +61,6 @@ var TRANSLATIONS = {
LOAD_APP: 'एप्लीकेशन लोड हो रही है…',
PURGE_INIT: 'डेटा की जाँच…',
PURGE_INFO: ({ count, percent }) => `${count} दस्तावेज साफ किए (${percent}% पूर्ण)…`,
PURGE_AFTER: 'ऑप्टिमाइज़िंग…',
LOAD_RULES: 'नियम लोड हो रहें हैं…',
STARTING_APP: 'ऐप शुरी की जा रही है…',
ERROR_MESSAGE: 'लोडिंग में त्रुटि, कृपया अपना कनेक्शन जांचें।',
Expand Down

0 comments on commit ac09b0b

Please sign in to comment.