From 50043f889bf5ac69f66f6863da906d4f91811537 Mon Sep 17 00:00:00 2001 From: soulsands <407221377@qq.com> Date: Sat, 8 Apr 2023 20:00:42 +0800 Subject: [PATCH] fix: remove duplication --- src/becca/similarity.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/becca/similarity.js b/src/becca/similarity.js index dadfb1ce5..2e7750100 100644 --- a/src/becca/similarity.js +++ b/src/becca/similarity.js @@ -2,7 +2,7 @@ const becca = require('./becca'); const log = require('../services/log'); const beccaService = require('./becca_service'); const dateUtils = require('../services/date_utils'); -const { JSDOM } = require("jsdom"); +const {JSDOM} = require("jsdom"); const DEBUG = false; @@ -168,7 +168,6 @@ function trimMime(mime) { } mimeCache[mime] = str; - mimeCache[mime] = str; } return mimeCache[mime]; @@ -224,8 +223,8 @@ function splitToWords(text) { */ function hasConnectingRelation(sourceNote, targetNote) { return sourceNote.getAttributes().find(attr => attr.type === 'relation' - && ['includenotelink', 'imagelink'].includes(attr.name) - && attr.value === targetNote.noteId); + && ['includenotelink', 'imagelink'].includes(attr.name) + && attr.value === targetNote.noteId); } async function findSimilarNotes(noteId) { @@ -301,7 +300,7 @@ async function findSimilarNotes(noteId) { for (const branch of parentNote.getParentBranches()) { score += gatherRewards(branch.prefix, 0.3) - + gatherAncestorRewards(branch.parentNote); + + gatherAncestorRewards(branch.parentNote); } } } @@ -314,7 +313,7 @@ async function findSimilarNotes(noteId) { function computeScore(candidateNote) { let score = gatherRewards(trimMime(candidateNote.mime)) - + gatherAncestorRewards(candidateNote); + + gatherAncestorRewards(candidateNote); if (candidateNote.isDecrypted) { score += gatherRewards(candidateNote.title); @@ -382,7 +381,7 @@ async function findSimilarNotes(noteId) { score += 1; } else if (utcDateCreated.substr(0, 10) === dateLimits.minDate.substr(0, 10) - || utcDateCreated.substr(0, 10) === dateLimits.maxDate.substr(0, 10)) { + || utcDateCreated.substr(0, 10) === dateLimits.maxDate.substr(0, 10)) { if (displayRewards) { console.log("Adding reward for same day of creation"); }