mirror of
https://github.com/zadam/trilium.git
synced 2025-01-14 19:19:28 +08:00
fix: remove duplication
This commit is contained in:
parent
49d1c5140e
commit
50043f889b
1 changed files with 6 additions and 7 deletions
|
@ -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");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue