sync fixes

This commit is contained in:
zadam 2021-02-10 22:56:23 +01:00
parent 18b13657fd
commit 8850de51f5
6 changed files with 22 additions and 5 deletions

View File

@ -65,3 +65,5 @@ DELETE FROM note_revision_contents WHERE noteRevisionId IN (
); );
DELETE FROM note_revisions WHERE isErased = 1; DELETE FROM note_revisions WHERE isErased = 1;
DELETE FROM notes WHERE isErased = 1; DELETE FROM notes WHERE isErased = 1;
UPDATE entity_changes SET isErased = COALESCE((SELECT isErased FROM entity_changes AS sub WHERE sub.entityId = entity_changes.entityId AND sub.entityName = 'note_revisions'), 0) WHERE entityName = 'note_revision_contents';

View File

@ -55,6 +55,15 @@ class Attribute {
return this.noteCache.notes[this.value]; return this.noteCache.notes[this.value];
} }
} }
// for logging etc
get pojo() {
const pojo = {...this};
delete pojo.noteCache;
return pojo;
}
} }
module.exports = Attribute; module.exports = Attribute;

View File

@ -333,14 +333,18 @@ async function findSimilarNotes(noteId) {
let value = attr.value; let value = attr.value;
let factor = 1; let factor = 1;
if (value.startsWith('http')) { if (!value) {
log.info(`Unexpected falsy value for attribute ${JSON.stringify(attr.pojo)}`);
continue;
}
else if (value.startsWith('http')) {
value = filterUrlValue(value); value = filterUrlValue(value);
// words in URLs are not that valuable // words in URLs are not that valuable
factor = 0.5; factor = 0.5;
} }
score += gatherRewards(attr.value, factor); score += gatherRewards(value, factor);
} }
if (candidateNote.type === baseNote.type) { if (candidateNote.type === baseNote.type) {

View File

@ -48,7 +48,7 @@ function initNotSyncedOptions(initialized, startNotePath = 'root', opts = {}) {
optionService.createOption('theme', opts.theme || 'white', false); optionService.createOption('theme', opts.theme || 'white', false);
optionService.createOption('syncServerHost', opts.syncServerHost || '', false); optionService.createOption('syncServerHost', opts.syncServerHost || '', false);
optionService.createOption('syncServerTimeout', '60000', false); optionService.createOption('syncServerTimeout', '120000', false);
optionService.createOption('syncProxy', opts.syncProxy || '', false); optionService.createOption('syncProxy', opts.syncProxy || '', false);
} }

View File

@ -158,7 +158,9 @@ async function pullChanges(syncContext) {
setLastSyncedPull(entityChanges[entityChanges.length - 1].entityChange.id); setLastSyncedPull(entityChanges[entityChanges.length - 1].entityChange.id);
}); });
log.info(`Pulled ${entityChanges.length} changes starting at entityChangeId=${lastSyncedPull} in ${pulledDate - startDate}ms and applied them in ${Date.now() - pulledDate}ms, ${outstandingPullCount} outstanding pulls`); const sizeInKb = Math.round(JSON.stringify(resp).length / 1024);
log.info(`Pulled ${entityChanges.length} changes in ${sizeInKb} KB, starting at entityChangeId=${lastSyncedPull} in ${pulledDate - startDate}ms and applied them in ${Date.now() - pulledDate}ms, ${outstandingPullCount} outstanding pulls`);
} }
if (atLeastOnePullApplied) { if (atLeastOnePullApplied) {

View File

@ -23,6 +23,6 @@ module.exports = {
// and we need to override it with config from config.ini // and we need to override it with config from config.ini
return !!syncServerHost && syncServerHost !== 'disabled'; return !!syncServerHost && syncServerHost !== 'disabled';
}, },
getSyncTimeout: () => parseInt(get('syncServerTimeout')) || 60000, getSyncTimeout: () => parseInt(get('syncServerTimeout')) || 120000,
getSyncProxy: () => get('syncProxy') getSyncProxy: () => get('syncProxy')
}; };