Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
renamed noteCache into becca
zadamf7e86c5be0ba
diff --git a/docs/backend_api/entities_note.js.html b/docs/backend_api/entities_note.js.htmlindex 20366f2d35..1e1e264825 100644--- a/docs/backend_api/entities_note.js.html+++ b/docs/backend_api/entities_note.js.html@@ -411,7 +411,7 @@ class Note extends Entity {return false;}- // FIXME: this code is quite questionable, one problem is that other caches (Froca, NoteCache) have nothing like that+ // FIXME: this code is quite questionable, one problem is that other caches (Froca, Becca) have nothing like thatif (attr.isDefinition()) {const firstDefinitionIndex = attributes.findIndex(el => el.type === attr.type && el.name === attr.name);diff --git a/spec/search/note_cache_mocking.js b/spec/search/note_cache_mocking.jsindex 2912fe0c21..fbdbf1ae48 100644--- a/spec/search/note_cache_mocking.js+++ b/spec/search/note_cache_mocking.js@@ -1,13 +1,13 @@const Note = require('../../src/services/note_cache/entities/note.js');const Branch = require('../../src/services/note_cache/entities/branch.js');const Attribute = require('../../src/services/note_cache/entities/attribute.js');-const noteCache = require('../../src/services/note_cache/note_cache.js');+const becca = require('../../src/services/note_cache/note_cache.js');const randtoken = require('rand-token').generator({source: 'crypto'});/** @return {Note} */function findNoteByTitle(searchResults, title) {return searchResults- .map(sr => noteCache.notes[sr.noteId])+ .map(sr => becca.notes[sr.noteId]).find(note => note.title === title);}@@ -17,7 +17,7 @@ class NoteBuilder {}label(name, value = '', isInheritable = false) {- new Attribute(noteCache, {+ new Attribute(becca, {attributeId: id(),noteId: this.note.noteId,type: 'label',@@ -30,7 +30,7 @@ class NoteBuilder {}relation(name, targetNote) {- new Attribute(noteCache, {+ new Attribute(becca, {attributeId: id(),noteId: this.note.noteId,type: 'relation',@@ -42,7 +42,7 @@ class NoteBuilder {}child(childNoteBuilder, prefix = "") {- new Branch(noteCache, {+ new Branch(becca, {branchId: id(),noteId: childNoteBuilder.note.noteId,parentNoteId: this.note.noteId,@@ -66,7 +66,7 @@ function note(title, extraParams = {}) {mime: 'text/html'}, extraParams);- const note = new Note(noteCache, row);+ const note = new Note(becca, row);return new NoteBuilder(note);}diff --git a/spec/search/parser.spec.js b/spec/search/parser.spec.jsindex 132db286e5..71325709ee 100644--- a/spec/search/parser.spec.js+++ b/spec/search/parser.spec.js@@ -37,7 +37,7 @@ describe("Parser", () => {expect(rootExp.constructor.name).toEqual("AndExp");expect(rootExp.subExpressions[0].constructor.name).toEqual("PropertyComparisonExp");expect(rootExp.subExpressions[1].constructor.name).toEqual("OrExp");- expect(rootExp.subExpressions[1].subExpressions[0].constructor.name).toEqual("NoteCacheFlatTextExp");+ expect(rootExp.subExpressions[1].subExpressions[0].constructor.name).toEqual("BeccaFlatTextExp");expect(rootExp.subExpressions[1].subExpressions[0].tokens).toEqual(["hello", "hi"]);});@@ -55,7 +55,7 @@ describe("Parser", () => {const subs = rootExp.subExpressions[1].subExpressions;- expect(subs[0].constructor.name).toEqual("NoteCacheFlatTextExp");+ expect(subs[0].constructor.name).toEqual("BeccaFlatTextExp");expect(subs[0].tokens).toEqual(["hello", "hi"]);expect(subs[1].constructor.name).toEqual("NoteContentProtectedFulltextExp");@@ -182,7 +182,7 @@ describe("Parser", () => {expect(firstSub.propertyName).toEqual('isArchived');expect(secondSub.constructor.name).toEqual("OrExp");- expect(secondSub.subExpressions[0].constructor.name).toEqual("NoteCacheFlatTextExp");+ expect(secondSub.subExpressions[0].constructor.name).toEqual("BeccaFlatTextExp");expect(secondSub.subExpressions[0].tokens).toEqual(["hello"]);expect(thirdSub.constructor.name).toEqual("LabelComparisonExp");diff --git a/spec/search/search.spec.js b/spec/search/search.spec.jsindex 2cdc00e57d..c8b35d9dc3 100644--- a/spec/search/search.spec.js+++ b/spec/search/search.spec.js@@ -3,17 +3,17 @@ const Note = require('../../src/services/note_cache/entities/note.js');const Branch = require('../../src/services/note_cache/entities/branch.js');const SearchContext = require('../../src/services/search/search_context.js');const dateUtils = require('../../src/services/date_utils.js');-const noteCache = require('../../src/services/note_cache/note_cache.js');+const becca = require('../../src/services/note_cache/note_cache.js');const {NoteBuilder, findNoteByTitle, note} = require('./note_cache_mocking.js');describe("Search", () => {let rootNote;beforeEach(() => {- noteCache.reset();+ becca.reset();- rootNote = new NoteBuilder(new Note(noteCache, {noteId: 'root', title: 'root', type: 'text'}));- new Branch(noteCache, {branchId: 'root', noteId: 'root', parentNoteId: 'none', notePosition: 10});+ rootNote = new NoteBuilder(new Note(becca, {noteId: 'root', title: 'root', type: 'text'}));+ new Branch(becca, {branchId: 'root', noteId: 'root', parentNoteId: 'none', notePosition: 10});});it("simple path match", () => {@@ -538,29 +538,29 @@ describe("Search", () => {let searchResults = searchService.findNotesWithQuery('# note.parents.title = Europe orderBy note.title', searchContext);expect(searchResults.length).toEqual(4);- expect(noteCache.notes[searchResults[0].noteId].title).toEqual("Austria");- expect(noteCache.notes[searchResults[1].noteId].title).toEqual("Italy");- expect(noteCache.notes[searchResults[2].noteId].title).toEqual("Slovakia");- expect(noteCache.notes[searchResults[3].noteId].title).toEqual("Ukraine");+ expect(becca.notes[searchResults[0].noteId].title).toEqual("Austria");+ expect(becca.notes[searchResults[1].noteId].title).toEqual("Italy");+ expect(becca.notes[searchResults[2].noteId].title).toEqual("Slovakia");+ expect(becca.notes[searchResults[3].noteId].title).toEqual("Ukraine");searchResults = searchService.findNotesWithQuery('# note.parents.title = Europe orderBy note.labels.capital', searchContext);expect(searchResults.length).toEqual(4);- expect(noteCache.notes[searchResults[0].noteId].title).toEqual("Slovakia");- expect(noteCache.notes[searchResults[1].noteId].title).toEqual("Ukraine");- expect(noteCache.notes[searchResults[2].noteId].title).toEqual("Italy");- expect(noteCache.notes[searchResults[3].noteId].title).toEqual("Austria");+ expect(becca.notes[searchResults[0].noteId].title).toEqual("Slovakia");+ expect(becca.notes[searchResults[1].noteId].title).toEqual("Ukraine");+ expect(becca.notes[searchResults[2].noteId].title).toEqual("Italy");+ expect(becca.notes[searchResults[3].noteId].title).toEqual("Austria");searchResults = searchService.findNotesWithQuery('# note.parents.title = Europe orderBy note.labels.capital DESC', searchContext);expect(searchResults.length).toEqual(4);- expect(noteCache.notes[searchResults[0].noteId].title).toEqual("Austria");- expect(noteCache.notes[searchResults[1].noteId].title).toEqual("Italy");- expect(noteCache.notes[searchResults[2].noteId].title).toEqual("Ukraine");- expect(noteCache.notes[searchResults[3].noteId].title).toEqual("Slovakia");+ expect(becca.notes[searchResults[0].noteId].title).toEqual("Austria");+ expect(becca.notes[searchResults[1].noteId].title).toEqual("Italy");+ expect(becca.notes[searchResults[2].noteId].title).toEqual("Ukraine");+ expect(becca.notes[searchResults[3].noteId].title).toEqual("Slovakia");searchResults = searchService.findNotesWithQuery('# note.parents.title = Europe orderBy note.labels.capital DESC limit 2', searchContext);expect(searchResults.length).toEqual(2);- expect(noteCache.notes[searchResults[0].noteId].title).toEqual("Austria");- expect(noteCache.notes[searchResults[1].noteId].title).toEqual("Italy");+ expect(becca.notes[searchResults[0].noteId].title).toEqual("Austria");+ expect(becca.notes[searchResults[1].noteId].title).toEqual("Italy");searchResults = searchService.findNotesWithQuery('# note.parents.title = Europe orderBy #capital DESC limit 1', searchContext);expect(searchResults.length).toEqual(1);@@ -582,11 +582,11 @@ describe("Search", () => {let searchResults = searchService.findNotesWithQuery('# not(#capital) and note.noteId != root', searchContext);expect(searchResults.length).toEqual(1);- expect(noteCache.notes[searchResults[0].noteId].title).toEqual("Europe");+ expect(becca.notes[searchResults[0].noteId].title).toEqual("Europe");searchResults = searchService.findNotesWithQuery('#!capital and note.noteId != root', searchContext);expect(searchResults.length).toEqual(1);- expect(noteCache.notes[searchResults[0].noteId].title).toEqual("Europe");+ expect(becca.notes[searchResults[0].noteId].title).toEqual("Europe");});it("test note.text *=* something", () => {@@ -602,7 +602,7 @@ describe("Search", () => {let searchResults = searchService.findNotesWithQuery('# note.text *=* vaki and note.noteId != root', searchContext);expect(searchResults.length).toEqual(1);- expect(noteCache.notes[searchResults[0].noteId].title).toEqual("Slovakia");+ expect(becca.notes[searchResults[0].noteId].title).toEqual("Slovakia");});it("test that fulltext does not match archived notes", () => {@@ -619,7 +619,7 @@ describe("Search", () => {let searchResults = searchService.findNotesWithQuery('reddit', searchContext);expect(searchResults.length).toEqual(1);- expect(noteCache.notes[searchResults[0].noteId].title).toEqual("Reddit is bad");+ expect(becca.notes[searchResults[0].noteId].title).toEqual("Reddit is bad");});// FIXME: test what happens when we order without any filter criteriadiff --git a/spec/search/value_extractor.spec.js b/spec/search/value_extractor.spec.jsindex 6262ecffba..3194967395 100644--- a/spec/search/value_extractor.spec.js+++ b/spec/search/value_extractor.spec.js@@ -1,13 +1,13 @@const {note} = require('./note_cache_mocking.js');const ValueExtractor = require('../../src/services/search/value_extractor.js');-const noteCache = require('../../src/services/note_cache/note_cache.js');+const becca = require('../../src/services/note_cache/note_cache.js');const SearchContext = require("../../src/services/search/search_context.js");const dsc = new SearchContext();describe("Value extractor", () => {beforeEach(() => {- noteCache.reset();+ becca.reset();});it("simple title extraction", async () => {diff --git a/src/entities/note.js b/src/entities/note.jsindex 290d2e4338..70b5c61400 100644--- a/src/entities/note.js+++ b/src/entities/note.js@@ -399,7 +399,7 @@ class Note extends Entity {return false;}- // FIXME: this code is quite questionable, one problem is that other caches (Froca, NoteCache) have nothing like that+ // FIXME: this code is quite questionable, one problem is that other caches (Froca, Becca) have nothing like thatif (attr.isDefinition()) {const firstDefinitionIndex = attributes.findIndex(el => el.type === attr.type && el.name === attr.name);diff --git a/src/routes/api/autocomplete.js b/src/routes/api/autocomplete.jsindex ec0ecfb048..ad4dde9699 100644--- a/src/routes/api/autocomplete.js+++ b/src/routes/api/autocomplete.js@@ -1,6 +1,6 @@"use strict";-const noteCacheService = require('../../services/note_cache/note_cache_service');+const beccaService = require('../../services/note_cache/note_cache_service');const searchService = require('../../services/search/services/search.js');const repository = require('../../services/repository');const log = require('../../services/log');@@ -58,8 +58,8 @@ function getRecentNotes(activeNoteId) {return recentNotes.map(rn => {const notePathArray = rn.notePath.split('/');- const noteTitle = noteCacheService.getNoteTitle(notePathArray[notePathArray.length - 1]);- const notePathTitle = noteCacheService.getNoteTitleForPath(notePathArray);+ const noteTitle = beccaService.getNoteTitle(notePathArray[notePathArray.length - 1]);+ const notePathTitle = beccaService.getNoteTitleForPath(notePathArray);return {notePath: rn.notePath,diff --git a/src/routes/api/branches.js b/src/routes/api/branches.jsindex bae85d01b3..f6a2ff5341 100644--- a/src/routes/api/branches.js+++ b/src/routes/api/branches.js@@ -5,7 +5,7 @@ const utils = require('../../services/utils');const entityChangesService = require('../../services/entity_changes.js');const treeService = require('../../services/tree');const noteService = require('../../services/notes');-const noteCache = require('../../services/note_cache/note_cache');+const becca = require('../../services/note_cache/note_cache');const repository = require('../../services/repository');const TaskContext = require('../../services/task_context');@@ -137,7 +137,7 @@ function setExpanded(req) {// we don't sync expanded label// also this does not trigger updates to the frontend, this would trigger too many reloads- const branch = noteCache.branches[branchId];+ const branch = becca.branches[branchId];if (branch) {branch.isExpanded = !!expanded;@@ -166,7 +166,7 @@ function setExpandedForSubtree(req) {sql.executeMany(`UPDATE branches SET isExpanded = ${expanded} WHERE branchId IN (???)`, branchIds);for (const branchId of branchIds) {- const branch = noteCache.branches[branchId];+ const branch = becca.branches[branchId];if (branch) {branch.isExpanded = !!expanded;diff --git a/src/routes/api/import.js b/src/routes/api/import.jsindex cd6ace2cc1..c593a80ee0 100644--- a/src/routes/api/import.js+++ b/src/routes/api/import.js@@ -7,7 +7,7 @@ const zipImportService = require('../../services/import/zip');const singleImportService = require('../../services/import/single');const cls = require('../../services/cls');const path = require('path');-const noteCacheLoader = require('../../services/note_cache/note_cache_loader.js');+const beccaLoader = require('../../services/note_cache/note_cache_loader.js');const log = require('../../services/log');const TaskContext = require('../../services/task_context.js');@@ -77,10 +77,10 @@ async function importToBranch(req) {}), 1000);}- // import has deactivated note events so note cache is not updated+ // import has deactivated note events so becca is not updated// instead we force it to reload (can be async)- noteCacheLoader.load();+ beccaLoader.load();return note;}diff --git a/src/routes/api/note_revisions.js b/src/routes/api/note_revisions.jsindex f6a7378636..39a861451c 100644--- a/src/routes/api/note_revisions.js+++ b/src/routes/api/note_revisions.js@@ -1,7 +1,7 @@"use strict";const repository = require('../../services/repository');-const noteCacheService = require('../../services/note_cache/note_cache_service');+const beccaService = require('../../services/note_cache/note_cache_service');const protectedSessionService = require('../../services/protected_session');const noteRevisionService = require('../../services/note_revisions');const utils = require('../../services/utils');@@ -121,7 +121,7 @@ function getEditedNotesOnDate(req) {LIMIT 50`, {date: req.params.date + '%'});for (const note of notes) {- const notePath = note.isDeleted ? null : noteCacheService.getNotePath(note.noteId);+ const notePath = note.isDeleted ? null : beccaService.getNotePath(note.noteId);note.notePath = notePath ? notePath.notePath : null;}diff --git a/src/routes/api/recent_changes.js b/src/routes/api/recent_changes.jsindex 5b1d9b3ef7..e264a66da6 100644--- a/src/routes/api/recent_changes.js+++ b/src/routes/api/recent_changes.js@@ -3,7 +3,7 @@const sql = require('../../services/sql');const protectedSessionService = require('../../services/protected_session');const noteService = require('../../services/notes');-const noteCacheService = require('../../services/note_cache/note_cache_service');+const beccaService = require('../../services/note_cache/note_cache_service');function getRecentChanges(req) {const {ancestorNoteId} = req.params;@@ -25,7 +25,7 @@ function getRecentChanges(req) {JOIN notes USING(noteId)`);for (const noteRevision of noteRevisions) {- if (noteCacheService.isInAncestor(noteRevision.noteId, ancestorNoteId)) {+ if (beccaService.isInAncestor(noteRevision.noteId, ancestorNoteId)) {recentChanges.push(noteRevision);}}@@ -58,7 +58,7 @@ function getRecentChanges(req) {WHERE notes.isDeleted = 1`);for (const note of notes) {- if (noteCacheService.isInAncestor(note.noteId, ancestorNoteId)) {+ if (beccaService.isInAncestor(note.noteId, ancestorNoteId)) {recentChanges.push(note);}}diff --git a/src/routes/api/stats.js b/src/routes/api/stats.jsindex a00b87cee3..3811004a26 100644--- a/src/routes/api/stats.js+++ b/src/routes/api/stats.js@@ -1,5 +1,5 @@const sql = require('../../services/sql');-const noteCache = require('../../services/note_cache/note_cache');+const becca = require('../../services/note_cache/note_cache');function getNoteSize(req) {const {noteId} = req.params;@@ -23,7 +23,7 @@ function getNoteSize(req) {function getSubtreeSize(req) {const {noteId} = req.params;- const note = noteCache.notes[noteId];+ const note = becca.notes[noteId];if (!note) {return [404, `Note ${noteId} was not found.`];diff --git a/src/routes/api/tree.js b/src/routes/api/tree.jsindex 0897266b31..702aee3e54 100644--- a/src/routes/api/tree.js+++ b/src/routes/api/tree.js@@ -1,6 +1,6 @@"use strict";-const noteCache = require('../../services/note_cache/note_cache');+const becca = require('../../services/note_cache/note_cache');const log = require('../../services/log');function getNotesAndBranchesAndAttributes(noteIds) {@@ -23,7 +23,7 @@ function getNotesAndBranchesAndAttributes(noteIds) {}for (const childNote of note.children) {- const childBranch = noteCache.getBranch(childNote.noteId, note.noteId);+ const childBranch = becca.getBranch(childNote.noteId, note.noteId);collectedBranchIds.add(childBranch.branchId);}@@ -38,7 +38,7 @@ function getNotesAndBranchesAndAttributes(noteIds) {}for (const noteId of noteIds) {- const note = noteCache.notes[noteId];+ const note = becca.notes[noteId];if (!note) {continue;@@ -50,7 +50,7 @@ function getNotesAndBranchesAndAttributes(noteIds) {const notes = [];for (const noteId of collectedNoteIds) {- const note = noteCache.notes[noteId];+ const note = becca.notes[noteId];notes.push({noteId: note.noteId,@@ -75,7 +75,7 @@ function getNotesAndBranchesAndAttributes(noteIds) {}for (const branchId of collectedBranchIds) {- const branch = noteCache.branches[branchId];+ const branch = becca.branches[branchId];if (!branch) {log.error(`Could not find branch for branchId=${branchId}`);@@ -95,7 +95,7 @@ function getNotesAndBranchesAndAttributes(noteIds) {const attributes = [];for (const attributeId of collectedAttributeIds) {- const attribute = noteCache.attributes[attributeId];+ const attribute = becca.attributes[attributeId];attributes.push({attributeId: attribute.attributeId,@@ -127,7 +127,7 @@ function getTree(req) {for (const childNote of parentNote.children) {collectedNoteIds.add(childNote.noteId);- const childBranch = noteCache.getBranch(childNote.noteId, parentNote.noteId);+ const childBranch = becca.getBranch(childNote.noteId, parentNote.noteId);if (childBranch.isExpanded) {collect(childBranch.childNote);@@ -135,11 +135,11 @@ function getTree(req) {}}- if (!(subTreeNoteId in noteCache.notes)) {+ if (!(subTreeNoteId in becca.notes)) {return [404, `Note ${subTreeNoteId} not found in the cache`];}- collect(noteCache.notes[subTreeNoteId]);+ collect(becca.notes[subTreeNoteId]);return getNotesAndBranchesAndAttributes(collectedNoteIds);}diff --git a/src/services/attributes.js b/src/services/attributes.jsindex 144a539f67..1f41bb348b 100644--- a/src/services/attributes.js+++ b/src/services/attributes.js@@ -2,7 +2,7 @@const repository = require('./repository');const sql = require('./sql');-const noteCache = require('./note_cache/note_cache');+const becca = require('./note_cache/note_cache');const Attribute = require('../entities/attribute');const ATTRIBUTE_TYPES = [ 'label', 'relation' ];@@ -75,7 +75,7 @@ function getNoteIdsWithLabels(names) {const noteIds = new Set();for (const name of names) {- for (const attr of noteCache.findAttributes('label', name)) {+ for (const attr of becca.findAttributes('label', name)) {noteIds.add(attr.noteId);}}diff --git a/src/services/handlers.js b/src/services/handlers.jsindex e0effba433..ef9c693c67 100644--- a/src/services/handlers.js+++ b/src/services/handlers.js@@ -3,7 +3,7 @@ const scriptService = require('./script');const treeService = require('./tree');const noteService = require('./notes');const repository = require('./repository');-const noteCache = require('./note_cache/note_cache');+const becca = require('./note_cache/note_cache');const Attribute = require('../entities/attribute');function runAttachedRelations(note, relationName, originEntity) {@@ -23,7 +23,7 @@ eventService.subscribe(eventService.NOTE_TITLE_CHANGED, note => {runAttachedRelations(note, 'runOnNoteTitleChange', note);if (!note.isRoot()) {- const noteFromCache = noteCache.notes[note.noteId];+ const noteFromCache = becca.notes[note.noteId];if (!noteFromCache) {return;@@ -87,7 +87,7 @@ eventService.subscribe(eventService.ENTITY_CREATED, ({ entityName, entity }) =>treeService.sortNotesByTitle(entity.noteId);if (entity.isInheritable) {- const note = noteCache.notes[entity.noteId];+ const note = becca.notes[entity.noteId];if (note) {for (const noteId of note.subtreeNoteIds) {diff --git a/src/services/note_cache/entities/attribute.js b/src/services/note_cache/entities/attribute.jsindex cfcdc0a23f..a616eab340 100644--- a/src/services/note_cache/entities/attribute.js+++ b/src/services/note_cache/entities/attribute.js@@ -3,9 +3,9 @@const Note = require('./note.js');class Attribute {- constructor(noteCache, row) {- /** @param {NoteCache} */- this.noteCache = noteCache;+ constructor(becca, row) {+ /** @param {Becca} */+ this.becca = becca;/** @param {string} */this.attributeId = row.attributeId;/** @param {string} */@@ -21,18 +21,18 @@ class Attribute {/** @param {boolean} */this.isInheritable = !!row.isInheritable;- this.noteCache.attributes[this.attributeId] = this;+ this.becca.attributes[this.attributeId] = this;- if (!(this.noteId in this.noteCache.notes)) {+ if (!(this.noteId in this.becca.notes)) {// entities can come out of order in sync, create skeleton which will be filled later- this.noteCache.notes[this.noteId] = new Note(this.noteCache, {noteId: this.noteId});+ this.becca.notes[this.noteId] = new Note(this.becca, {noteId: this.noteId});}- this.noteCache.notes[this.noteId].ownedAttributes.push(this);+ this.becca.notes[this.noteId].ownedAttributes.push(this);const key = `${this.type}-${this.name.toLowerCase()}`;- this.noteCache.attributeIndex[key] = this.noteCache.attributeIndex[key] || [];- this.noteCache.attributeIndex[key].push(this);+ this.becca.attributeIndex[key] = this.becca.attributeIndex[key] || [];+ this.becca.attributeIndex[key].push(this);const targetNote = this.targetNote;@@ -51,12 +51,12 @@ class Attribute {}get note() {- return this.noteCache.notes[this.noteId];+ return this.becca.notes[this.noteId];}get targetNote() {if (this.type === 'relation') {- return this.noteCache.notes[this.value];+ return this.becca.notes[this.value];}}@@ -64,7 +64,7 @@ class Attribute {get pojo() {const pojo = {...this};- delete pojo.noteCache;+ delete pojo.becca;return pojo;}diff --git a/src/services/note_cache/entities/branch.js b/src/services/note_cache/entities/branch.jsindex 55edfc650a..409ff53d3a 100644--- a/src/services/note_cache/entities/branch.js+++ b/src/services/note_cache/entities/branch.js@@ -3,9 +3,9 @@const Note = require('./note.js');class Branch {- constructor(noteCache, row) {- /** @param {NoteCache} */- this.noteCache = noteCache;+ constructor(becca, row) {+ /** @param {Becca} */+ this.becca = becca;/** @param {string} */this.branchId = row.branchId;/** @param {string} */@@ -31,35 +31,35 @@ class Branch {parentNote.children.push(childNote);- this.noteCache.branches[this.branchId] = this;- this.noteCache.childParentToBranch[`${this.noteId}-${this.parentNoteId}`] = this;+ this.becca.branches[this.branchId] = this;+ this.becca.childParentToBranch[`${this.noteId}-${this.parentNoteId}`] = this;}/** @return {Note} */get childNote() {- if (!(this.noteId in this.noteCache.notes)) {+ if (!(this.noteId in this.becca.notes)) {// entities can come out of order in sync, create skeleton which will be filled later- this.noteCache.notes[this.noteId] = new Note(this.noteCache, {noteId: this.noteId});+ this.becca.notes[this.noteId] = new Note(this.becca, {noteId: this.noteId});}- return this.noteCache.notes[this.noteId];+ return this.becca.notes[this.noteId];}/** @return {Note} */get parentNote() {- if (!(this.parentNoteId in this.noteCache.notes)) {+ if (!(this.parentNoteId in this.becca.notes)) {// entities can come out of order in sync, create skeleton which will be filled later- this.noteCache.notes[this.parentNoteId] = new Note(this.noteCache, {noteId: this.parentNoteId});+ this.becca.notes[this.parentNoteId] = new Note(this.becca, {noteId: this.parentNoteId});}- return this.noteCache.notes[this.parentNoteId];+ return this.becca.notes[this.parentNoteId];}// for logging etcget pojo() {const pojo = {...this};- delete pojo.noteCache;+ delete pojo.becca;return pojo;}diff --git a/src/services/note_cache/entities/note.js b/src/services/note_cache/entities/note.jsindex 9ac9b2b197..7d5f63c5e6 100644--- a/src/services/note_cache/entities/note.js+++ b/src/services/note_cache/entities/note.js@@ -4,9 +4,9 @@ const protectedSessionService = require('../../protected_session');const log = require('../../log');class Note {- constructor(noteCache, row) {- /** @param {NoteCache} */- this.noteCache = noteCache;+ constructor(becca, row) {+ /** @param {Becca} */+ this.becca = becca;this.update(row);@@ -27,7 +27,7 @@ class Note {/** @param {Attribute[]} */this.targetRelations = [];- this.noteCache.notes[this.noteId] = this;+ this.becca.notes[this.noteId] = this;/** @param {Note[]|null} */this.ancestorCache = null;@@ -94,7 +94,7 @@ class Note {for (const ownedAttr of parentAttributes) { // parentAttributes so we process also inherited templatesif (ownedAttr.type === 'relation' && ownedAttr.name === 'template') {- const templateNote = this.noteCache.notes[ownedAttr.value];+ const templateNote = this.becca.notes[ownedAttr.value];if (templateNote) {templateAttributes.push(...templateNote.__getAttributes(newPath));@@ -440,7 +440,7 @@ class Note {get pojo() {const pojo = {...this};- delete pojo.noteCache;+ delete pojo.becca;delete pojo.ancestorCache;delete pojo.attributeCache;delete pojo.flatTextCache;diff --git a/src/services/note_cache/note_cache.js b/src/services/note_cache/note_cache.jsindex f6c943a3fb..27662ed958 100644--- a/src/services/note_cache/note_cache.js+++ b/src/services/note_cache/note_cache.js@@ -1,6 +1,6 @@"use strict";-class NoteCache {+class Becca {constructor() {this.reset();}@@ -50,6 +50,6 @@ class NoteCache {}}-const noteCache = new NoteCache();+const becca = new Becca();-module.exports = noteCache;+module.exports = becca;diff --git a/src/services/note_cache/note_cache_loader.js b/src/services/note_cache/note_cache_loader.jsindex 4c51b88832..0d25b80379 100644--- a/src/services/note_cache/note_cache_loader.js+++ b/src/services/note_cache/note_cache_loader.js@@ -2,7 +2,7 @@const sql = require('../sql.js');const eventService = require('../events.js');-const noteCache = require('./note_cache');+const becca = require('./note_cache');const sqlInit = require('../sql_init');const log = require('../log');const Note = require('./entities/note');@@ -15,29 +15,29 @@ sqlInit.dbReady.then(() => {function load() {const start = Date.now();- noteCache.reset();+ becca.reset();for (const row of sql.iterateRows(`SELECT noteId, title, type, mime, isProtected, dateCreated, dateModified, utcDateCreated, utcDateModified FROM notes WHERE isDeleted = 0`, [])) {- new Note(noteCache, row);+ new Note(becca, row);}for (const row of sql.iterateRows(`SELECT branchId, noteId, parentNoteId, prefix, notePosition, isExpanded FROM branches WHERE isDeleted = 0`, [])) {- const branch = new Branch(noteCache, row);+ const branch = new Branch(becca, row);}for (const row of sql.iterateRows(`SELECT attributeId, noteId, type, name, value, isInheritable, position FROM attributes WHERE isDeleted = 0`, [])) {- new Attribute(noteCache, row);+ new Attribute(becca, row);}- noteCache.loaded = true;+ becca.loaded = true;- log.info(`Note cache load took ${Date.now() - start}ms`);+ log.info(`Becca (note cache) load took ${Date.now() - start}ms`);}eventService.subscribe([eventService.ENTITY_CHANGED, eventService.ENTITY_DELETED, eventService.ENTITY_SYNCED], ({entityName, entity}) => {// note that entity can also be just POJO without methods if coming from sync- if (!noteCache.loaded) {+ if (!becca.loaded) {return;}@@ -45,20 +45,20 @@ eventService.subscribe([eventService.ENTITY_CHANGED, eventService.ENTITY_DELETEDconst {noteId} = entity;if (entity.isDeleted) {- delete noteCache.notes[noteId];+ delete becca.notes[noteId];}- else if (noteId in noteCache.notes) {- noteCache.notes[noteId].update(entity);+ else if (noteId in becca.notes) {+ becca.notes[noteId].update(entity);}else {- const note = new Note(noteCache, entity);+ const note = new Note(becca, entity);note.decrypt();}}else if (entityName === 'branches') {const {branchId, noteId, parentNoteId} = entity;- const childNote = noteCache.notes[noteId];+ const childNote = becca.notes[noteId];if (entity.isDeleted) {if (childNote) {@@ -70,26 +70,26 @@ eventService.subscribe([eventService.ENTITY_CHANGED, eventService.ENTITY_DELETED}}- const parentNote = noteCache.notes[parentNoteId];+ const parentNote = becca.notes[parentNoteId];if (parentNote) {parentNote.children = parentNote.children.filter(child => child.noteId !== noteId);}- delete noteCache.childParentToBranch[`${noteId}-${parentNoteId}`];- delete noteCache.branches[branchId];+ delete becca.childParentToBranch[`${noteId}-${parentNoteId}`];+ delete becca.branches[branchId];}- else if (branchId in noteCache.branches) {+ else if (branchId in becca.branches) {// only relevant properties which can change in a branch are prefix and isExpanded- noteCache.branches[branchId].prefix = entity.prefix;- noteCache.branches[branchId].isExpanded = entity.isExpanded;+ becca.branches[branchId].prefix = entity.prefix;+ becca.branches[branchId].isExpanded = entity.isExpanded;if (childNote) {childNote.flatTextCache = null;}}else {- noteCache.branches[branchId] = new Branch(noteCache, entity);+ becca.branches[branchId] = new Branch(becca, entity);if (childNote) {childNote.resortParents();@@ -98,8 +98,8 @@ eventService.subscribe([eventService.ENTITY_CHANGED, eventService.ENTITY_DELETED}else if (entityName === 'attributes') {const {attributeId, noteId} = entity;- const note = noteCache.notes[noteId];- const attr = noteCache.attributes[attributeId];+ const note = becca.notes[noteId];+ const attr = becca.attributes[attributeId];if (entity.isDeleted) {if (note && attr) {@@ -119,18 +119,18 @@ eventService.subscribe([eventService.ENTITY_CHANGED, eventService.ENTITY_DELETED}}- delete noteCache.attributes[attributeId];+ delete becca.attributes[attributeId];if (attr) {const key = `${attr.type}-${attr.name.toLowerCase()}`;- if (key in noteCache.attributeIndex) {- noteCache.attributeIndex[key] = noteCache.attributeIndex[key].filter(attr => attr.attributeId !== attributeId);+ if (key in becca.attributeIndex) {+ becca.attributeIndex[key] = becca.attributeIndex[key].filter(attr => attr.attributeId !== attributeId);}}}- else if (attributeId in noteCache.attributes) {- const attr = noteCache.attributes[attributeId];+ else if (attributeId in becca.attributes) {+ const attr = becca.attributes[attributeId];// attr name and isInheritable are immutableattr.value = entity.value;@@ -143,7 +143,7 @@ eventService.subscribe([eventService.ENTITY_CHANGED, eventService.ENTITY_DELETED}}else {- const attr = new Attribute(noteCache, entity);+ const attr = new Attribute(becca, entity);if (note) {if (attr.isAffectingSubtree || note.isTemplate) {@@ -159,7 +159,7 @@ eventService.subscribe([eventService.ENTITY_CHANGED, eventService.ENTITY_DELETEDconst parentNoteIds = new Set();for (const branchId in entity) {- const branch = noteCache.branches[branchId];+ const branch = becca.branches[branchId];if (branch) {branch.notePosition = entity[branchId];@@ -172,7 +172,7 @@ eventService.subscribe([eventService.ENTITY_CHANGED, eventService.ENTITY_DELETEDeventService.subscribe(eventService.ENTER_PROTECTED_SESSION, () => {try {- noteCache.decryptProtectedNotes();+ becca.decryptProtectedNotes();}catch (e) {log.error(`Could not decrypt protected notes: ${e.message} ${e.stack}`);diff --git a/src/services/note_cache/note_cache_service.js b/src/services/note_cache/note_cache_service.jsindex 3d685c6810..0f6a26c9e7 100644--- a/src/services/note_cache/note_cache_service.js+++ b/src/services/note_cache/note_cache_service.js@@ -1,20 +1,20 @@"use strict";-const noteCache = require('./note_cache');+const becca = require('./note_cache');const cls = require('../cls');const protectedSessionService = require('../protected_session');const log = require('../log');function isNotePathArchived(notePath) {const noteId = notePath[notePath.length - 1];- const note = noteCache.notes[noteId];+ const note = becca.notes[noteId];if (note.isArchived) {return true;}for (let i = 0; i < notePath.length - 1; i++) {- const note = noteCache.notes[notePath[i]];+ const note = becca.notes[notePath[i]];// this is going through parents so archived must be inheritableif (note.hasInheritableOwnedArchivedLabel) {@@ -47,7 +47,7 @@ function isInAncestor(noteId, ancestorNoteId) {return true;}- const note = noteCache.notes[noteId];+ const note = becca.notes[noteId];if (!note) {return false;@@ -63,8 +63,8 @@ function isInAncestor(noteId, ancestorNoteId) {}function getNoteTitle(childNoteId, parentNoteId) {- const childNote = noteCache.notes[childNoteId];- const parentNote = noteCache.notes[parentNoteId];+ const childNote = becca.notes[childNoteId];+ const parentNote = becca.notes[parentNoteId];if (!childNote) {log.info(`Cannot find note in cache for noteId ${childNoteId}`);@@ -80,7 +80,7 @@ function getNoteTitle(childNoteId, parentNoteId) {title = childNote.title;}- const branch = parentNote ? noteCache.getBranch(childNote.noteId, parentNote.noteId) : null;+ const branch = parentNote ? becca.getBranch(childNote.noteId, parentNote.noteId) : null;return ((branch && branch.prefix) ? `${branch.prefix} - ` : '') + title;}@@ -160,7 +160,7 @@ function getSomePathInner(note, path, respectHoistng) {}function getNotePath(noteId) {- const note = noteCache.notes[noteId];+ const note = becca.notes[noteId];if (!note) {console.trace(`Cannot find note ${noteId} in cache.`);@@ -175,7 +175,7 @@ function getNotePath(noteId) {return {noteId: noteId,- branchId: noteCache.getBranch(noteId, parentNote.noteId).branchId,+ branchId: becca.getBranch(noteId, parentNote.noteId).branchId,title: noteTitle,notePath: retPath,path: retPath.join('/')diff --git a/src/services/note_cache/similarity.js b/src/services/note_cache/similarity.jsindex 6046e272b3..0845ef872d 100644--- a/src/services/note_cache/similarity.js+++ b/src/services/note_cache/similarity.js@@ -1,6 +1,6 @@-const noteCache = require('./note_cache');+const becca = require('./note_cache');const log = require('../log');-const noteCacheService = require('./note_cache_service.js');+const beccaService = require('./note_cache_service.js');const dateUtils = require('../date_utils');const repository = require('../repository');const { JSDOM } = require("jsdom");@@ -231,7 +231,7 @@ async function findSimilarNotes(noteId) {const results = [];let i = 0;- const baseNote = noteCache.notes[noteId];+ const baseNote = becca.notes[noteId];if (!baseNote || !baseNote.utcDateCreated) {return [];@@ -394,7 +394,7 @@ async function findSimilarNotes(noteId) {return score;}- for (const candidateNote of Object.values(noteCache.notes)) {+ for (const candidateNote of Object.values(becca.notes)) {if (candidateNote.noteId === baseNote.noteId|| hasConnectingRelation(candidateNote, baseNote)|| hasConnectingRelation(baseNote, candidateNote)) {@@ -404,14 +404,14 @@ async function findSimilarNotes(noteId) {let score = computeScore(candidateNote);if (score >= 1.5) {- const notePath = noteCacheService.getSomePath(candidateNote);+ const notePath = beccaService.getSomePath(candidateNote);// this takes care of note hoistingif (!notePath) {return;}- if (noteCacheService.isNotePathArchived(notePath)) {+ if (beccaService.isNotePathArchived(notePath)) {score -= 0.5; // archived penalization}@@ -432,7 +432,7 @@ async function findSimilarNotes(noteId) {if (results.length >= 1) {for (const {noteId} of results) {- const note = noteCache.notes[noteId];+ const note = becca.notes[noteId];console.log("NOTE", note.pojo);diff --git a/src/services/search/expressions/ancestor.js b/src/services/search/expressions/ancestor.jsindex b41e605079..298072ee17 100644--- a/src/services/search/expressions/ancestor.js+++ b/src/services/search/expressions/ancestor.js@@ -3,7 +3,7 @@const Expression = require('./expression');const NoteSet = require('../note_set');const log = require('../../log');-const noteCache = require('../../note_cache/note_cache');+const becca = require('../../note_cache/note_cache');class AncestorExp extends Expression {constructor(ancestorNoteId, ancestorDepth) {@@ -15,7 +15,7 @@ class AncestorExp extends Expression {}execute(inputNoteSet, executionContext) {- const ancestorNote = noteCache.notes[this.ancestorNoteId];+ const ancestorNote = becca.notes[this.ancestorNoteId];if (!ancestorNote) {log.error(`Subtree note '${this.ancestorNoteId}' was not not found.`);diff --git a/src/services/search/expressions/attribute_exists.js b/src/services/search/expressions/attribute_exists.jsindex b368ab92af..53b1b3b810 100644--- a/src/services/search/expressions/attribute_exists.js+++ b/src/services/search/expressions/attribute_exists.js@@ -1,7 +1,7 @@"use strict";const NoteSet = require('../note_set');-const noteCache = require('../../note_cache/note_cache');+const becca = require('../../note_cache/note_cache');const Expression = require('./expression');class AttributeExistsExp extends Expression {@@ -15,8 +15,8 @@ class AttributeExistsExp extends Expression {execute(inputNoteSet) {const attrs = this.prefixMatch- ? noteCache.findAttributesWithPrefix(this.attributeType, this.attributeName)- : noteCache.findAttributes(this.attributeType, this.attributeName);+ ? becca.findAttributesWithPrefix(this.attributeType, this.attributeName)+ : becca.findAttributes(this.attributeType, this.attributeName);const resultNoteSet = new NoteSet();diff --git a/src/services/search/expressions/descendant_of.js b/src/services/search/expressions/descendant_of.jsindex f6ad97ce42..4b27536ec5 100644--- a/src/services/search/expressions/descendant_of.js+++ b/src/services/search/expressions/descendant_of.js@@ -2,7 +2,7 @@const Expression = require('./expression');const NoteSet = require('../note_set');-const noteCache = require('../../note_cache/note_cache');+const becca = require('../../note_cache/note_cache');class DescendantOfExp extends Expression {constructor(subExpression) {@@ -12,7 +12,7 @@ class DescendantOfExp extends Expression {}execute(inputNoteSet, executionContext) {- const subInputNoteSet = new NoteSet(Object.values(noteCache.notes));+ const subInputNoteSet = new NoteSet(Object.values(becca.notes));const subResNoteSet = this.subExpression.execute(subInputNoteSet, executionContext);const subTreeNoteSet = new NoteSet();diff --git a/src/services/search/expressions/label_comparison.js b/src/services/search/expressions/label_comparison.jsindex 817fe5c28c..a011c8b3cc 100644--- a/src/services/search/expressions/label_comparison.js+++ b/src/services/search/expressions/label_comparison.js@@ -2,7 +2,7 @@const Expression = require('./expression');const NoteSet = require('../note_set');-const noteCache = require('../../note_cache/note_cache');+const becca = require('../../note_cache/note_cache');class LabelComparisonExp extends Expression {constructor(attributeType, attributeName, comparator) {@@ -14,7 +14,7 @@ class LabelComparisonExp extends Expression {}execute(inputNoteSet) {- const attrs = noteCache.findAttributes(this.attributeType, this.attributeName);+ const attrs = becca.findAttributes(this.attributeType, this.attributeName);const resultNoteSet = new NoteSet();for (const attr of attrs) {diff --git a/src/services/search/expressions/note_cache_flat_text.js b/src/services/search/expressions/note_cache_flat_text.jsindex a3d7323f55..c952bb8a54 100644--- a/src/services/search/expressions/note_cache_flat_text.js+++ b/src/services/search/expressions/note_cache_flat_text.js@@ -2,9 +2,9 @@const Expression = require('./expression');const NoteSet = require('../note_set');-const noteCache = require('../../note_cache/note_cache');+const becca = require('../../note_cache/note_cache');-class NoteCacheFlatTextExp extends Expression {+class BeccaFlatTextExp extends Expression {constructor(tokens) {super();@@ -13,18 +13,18 @@ class NoteCacheFlatTextExp extends Expression {execute(inputNoteSet, executionContext) {// has deps on SQL which breaks unit test so needs to be dynamically required- const noteCacheService = require('../../note_cache/note_cache_service');+ const beccaService = require('../../note_cache/note_cache_service');const resultNoteSet = new NoteSet();function searchDownThePath(note, tokens, path) {if (tokens.length === 0) {- const retPath = noteCacheService.getSomePath(note, path);+ const retPath = beccaService.getSomePath(note, path);if (retPath) {const noteId = retPath[retPath.length - 1];executionContext.noteIdToNotePath[noteId] = retPath;- resultNoteSet.add(noteCache.notes[noteId]);+ resultNoteSet.add(becca.notes[noteId]);}return;@@ -52,7 +52,7 @@ class NoteCacheFlatTextExp extends Expression {}for (const parentNote of note.parents) {- const title = noteCacheService.getNoteTitle(note.noteId, parentNote.noteId).toLowerCase();+ const title = beccaService.getNoteTitle(note.noteId, parentNote.noteId).toLowerCase();const foundTokens = foundAttrTokens.slice();for (const token of tokens) {@@ -98,7 +98,7 @@ class NoteCacheFlatTextExp extends Expression {}for (const parentNote of note.parents) {- const title = noteCacheService.getNoteTitle(note.noteId, parentNote.noteId).toLowerCase();+ const title = beccaService.getNoteTitle(note.noteId, parentNote.noteId).toLowerCase();const foundTokens = foundAttrTokens.slice();for (const token of this.tokens) {@@ -140,4 +140,4 @@ class NoteCacheFlatTextExp extends Expression {}}-module.exports = NoteCacheFlatTextExp;+module.exports = BeccaFlatTextExp;diff --git a/src/services/search/expressions/note_content_protected_fulltext.js b/src/services/search/expressions/note_content_protected_fulltext.jsindex c66645865f..c977ee53d5 100644--- a/src/services/search/expressions/note_content_protected_fulltext.js+++ b/src/services/search/expressions/note_content_protected_fulltext.js@@ -3,7 +3,7 @@const Expression = require('./expression');const NoteSet = require('../note_set');const log = require('../../log');-const noteCache = require('../../note_cache/note_cache');+const becca = require('../../note_cache/note_cache');const protectedSessionService = require('../../protected_session');const striptags = require('striptags');@@ -33,7 +33,7 @@ class NoteContentProtectedFulltextExp extends Expression {FROM notes JOIN note_contents USING (noteId)WHERE type IN ('text', 'code') AND isDeleted = 0 AND isProtected = 1`)) {- if (!inputNoteSet.hasNoteId(noteId) || !(noteId in noteCache.notes)) {+ if (!inputNoteSet.hasNoteId(noteId) || !(noteId in becca.notes)) {continue;}@@ -56,7 +56,7 @@ class NoteContentProtectedFulltextExp extends Expression {}if (!this.tokens.find(token => !content.includes(token))) {- resultNoteSet.add(noteCache.notes[noteId]);+ resultNoteSet.add(becca.notes[noteId]);}}diff --git a/src/services/search/expressions/note_content_unprotected_fulltext.js b/src/services/search/expressions/note_content_unprotected_fulltext.jsindex aace6a115c..b621f7e4fe 100644--- a/src/services/search/expressions/note_content_unprotected_fulltext.js+++ b/src/services/search/expressions/note_content_unprotected_fulltext.js@@ -2,7 +2,7 @@const Expression = require('./expression');const NoteSet = require('../note_set');-const noteCache = require('../../note_cache/note_cache');+const becca = require('../../note_cache/note_cache');const striptags = require('striptags');class NoteContentUnprotectedFulltextExp extends Expression {@@ -27,7 +27,7 @@ class NoteContentUnprotectedFulltextExp extends Expression {FROM notes JOIN note_contents USING (noteId)WHERE type IN ('text', 'code') AND isDeleted = 0 AND isProtected = 0`)) {- if (!inputNoteSet.hasNoteId(noteId) || !(noteId in noteCache.notes)) {+ if (!inputNoteSet.hasNoteId(noteId) || !(noteId in becca.notes)) {continue;}@@ -42,7 +42,7 @@ class NoteContentUnprotectedFulltextExp extends Expression {}if (!this.tokens.find(token => !content.includes(token))) {- resultNoteSet.add(noteCache.notes[noteId]);+ resultNoteSet.add(becca.notes[noteId]);}}diff --git a/src/services/search/expressions/relation_where.js b/src/services/search/expressions/relation_where.jsindex 8f463a9927..608c25b440 100644--- a/src/services/search/expressions/relation_where.js+++ b/src/services/search/expressions/relation_where.js@@ -2,7 +2,7 @@const Expression = require('./expression');const NoteSet = require('../note_set');-const noteCache = require('../../note_cache/note_cache');+const becca = require('../../note_cache/note_cache');class RelationWhereExp extends Expression {constructor(relationName, subExpression) {@@ -15,7 +15,7 @@ class RelationWhereExp extends Expression {execute(inputNoteSet, executionContext) {const candidateNoteSet = new NoteSet();- for (const attr of noteCache.findAttributes('relation', this.relationName)) {+ for (const attr of becca.findAttributes('relation', this.relationName)) {const note = attr.note;if (inputNoteSet.hasNoteId(note.noteId) && attr.targetNote) {diff --git a/src/services/search/search_context.js b/src/services/search/search_context.jsindex 9d3cbd3719..965a2b10bd 100644--- a/src/services/search/search_context.js+++ b/src/services/search/search_context.js@@ -21,7 +21,7 @@ class SearchContext {this.fuzzyAttributeSearch = !!params.fuzzyAttributeSearch;this.highlightedTokens = [];this.originalQuery = "";- // if true, note cache does not have (up-to-date) information needed to process the query+ // if true, becca does not have (up-to-date) information needed to process the query// and some extra data needs to be loaded before executingthis.dbLoadNeeded = false;this.error = null;diff --git a/src/services/search/search_result.js b/src/services/search/search_result.jsindex a354cfdb71..bab4597dce 100644--- a/src/services/search/search_result.js+++ b/src/services/search/search_result.js@@ -1,11 +1,11 @@"use strict";-const noteCacheService = require('../note_cache/note_cache_service');+const beccaService = require('../note_cache/note_cache_service');class SearchResult {constructor(notePathArray) {this.notePathArray = notePathArray;- this.notePathTitle = noteCacheService.getNoteTitleForPath(notePathArray);+ this.notePathTitle = beccaService.getNoteTitleForPath(notePathArray);}get notePath() {diff --git a/src/services/search/services/parse.js b/src/services/search/services/parse.jsindex 2371c318c7..04af0db798 100644--- a/src/services/search/services/parse.js+++ b/src/services/search/services/parse.js@@ -11,7 +11,7 @@ const RelationWhereExp = require('../expressions/relation_where.js');const PropertyComparisonExp = require('../expressions/property_comparison.js');const AttributeExistsExp = require('../expressions/attribute_exists.js');const LabelComparisonExp = require('../expressions/label_comparison.js');-const NoteCacheFlatTextExp = require('../expressions/note_cache_flat_text.js');+const BeccaFlatTextExp = require('../expressions/note_cache_flat_text.js');const NoteContentProtectedFulltextExp = require('../expressions/note_content_protected_fulltext.js');const NoteContentUnprotectedFulltextExp = require('../expressions/note_content_unprotected_fulltext.js');const OrderByAndLimitExp = require('../expressions/order_by_and_limit.js');@@ -30,13 +30,13 @@ function getFulltext(tokens, searchContext) {if (!searchContext.fastSearch) {return new OrExp([- new NoteCacheFlatTextExp(tokens),+ new BeccaFlatTextExp(tokens),new NoteContentProtectedFulltextExp('*=*', tokens),new NoteContentUnprotectedFulltextExp('*=*', tokens)]);}else {- return new NoteCacheFlatTextExp(tokens);+ return new BeccaFlatTextExp(tokens);}}diff --git a/src/services/search/services/search.js b/src/services/search/services/search.jsindex 1550abe605..b3312b7554 100644--- a/src/services/search/services/search.js+++ b/src/services/search/services/search.js@@ -6,18 +6,18 @@ const parse = require('./parse.js');const NoteSet = require("../note_set.js");const SearchResult = require("../search_result.js");const SearchContext = require("../search_context.js");-const noteCache = require('../../note_cache/note_cache.js');-const noteCacheService = require('../../note_cache/note_cache_service.js');+const becca = require('../../note_cache/note_cache.js');+const beccaService = require('../../note_cache/note_cache_service.js');const utils = require('../../utils.js');const log = require('../../log.js');function loadNeededInfoFromDatabase() {const sql = require('../../sql.js');- for (const noteId in noteCache.notes) {- noteCache.notes[noteId].contentSize = 0;- noteCache.notes[noteId].noteSize = 0;- noteCache.notes[noteId].revisionCount = 0;+ for (const noteId in becca.notes) {+ becca.notes[noteId].contentSize = 0;+ becca.notes[noteId].noteSize = 0;+ becca.notes[noteId].revisionCount = 0;}const noteContentLengths = sql.getRows(`@@ -29,13 +29,13 @@ function loadNeededInfoFromDatabase() {WHERE notes.isDeleted = 0`);for (const {noteId, length} of noteContentLengths) {- if (!(noteId in noteCache.notes)) {- log.error(`Note ${noteId} not found in note cache.`);+ if (!(noteId in becca.notes)) {+ log.error(`Note ${noteId} not found in becca.`);continue;}- noteCache.notes[noteId].contentSize = length;- noteCache.notes[noteId].noteSize = length;+ becca.notes[noteId].contentSize = length;+ becca.notes[noteId].noteSize = length;}const noteRevisionContentLengths = sql.getRows(`@@ -48,13 +48,13 @@ function loadNeededInfoFromDatabase() {WHERE notes.isDeleted = 0`);for (const {noteId, length} of noteRevisionContentLengths) {- if (!(noteId in noteCache.notes)) {- log.error(`Note ${noteId} not found in note cache.`);+ if (!(noteId in becca.notes)) {+ log.error(`Note ${noteId} not found in becca.`);continue;}- noteCache.notes[noteId].noteSize += length;- noteCache.notes[noteId].revisionCount++;+ becca.notes[noteId].noteSize += length;+ becca.notes[noteId].revisionCount++;}}@@ -64,7 +64,7 @@ function loadNeededInfoFromDatabase() {* @return {SearchResult[]}*/function findNotesWithExpression(expression, searchContext) {- let allNotes = Object.values(noteCache.notes);+ let allNotes = Object.values(becca.notes);if (searchContext.dbLoadNeeded) {loadNeededInfoFromDatabase();@@ -84,7 +84,7 @@ function findNotesWithExpression(expression, searchContext) {const searchResults = noteSet.notes.map(note => new SearchResult(- executionContext.noteIdToNotePath[note.noteId] || noteCacheService.getSomePath(note)+ executionContext.noteIdToNotePath[note.noteId] || beccaService.getSomePath(note)));for (const res of searchResults) {@@ -174,7 +174,7 @@ function searchNotesForAutocomplete(query) {return results.map(result => {return {notePath: result.notePath,- noteTitle: noteCacheService.getNoteTitle(result.noteId),+ noteTitle: beccaService.getNoteTitle(result.noteId),notePathTitle: result.notePathTitle,highlightedNotePathTitle: result.highlightedNotePathTitle}@@ -194,7 +194,7 @@ function highlightSearchResults(searchResults, highlightedTokens) {highlightedTokens.sort((a, b) => a.length > b.length ? -1 : 1);for (const result of searchResults) {- const note = noteCache.notes[result.noteId];+ const note = becca.notes[result.noteId];result.highlightedNotePathTitle = result.notePathTitle.replace('/[<\{\}]/g', '');diff --git a/src/services/sql.js b/src/services/sql.jsindex 0210e29f4e..ea05ddb778 100644--- a/src/services/sql.js+++ b/src/services/sql.js@@ -247,7 +247,7 @@ function transactional(func) {const entityChanges = cls.getAndClearEntityChanges();if (entityChanges.length > 0) {- log.info("Transaction rollback dirtied the note cache, forcing reload.");+ log.info("Transaction rollback dirtied the becca, forcing reload.");require('./note_cache/note_cache_loader').load();}diff --git a/src/services/tree.js b/src/services/tree.jsindex 98d1b6205a..098f9e054b 100644--- a/src/services/tree.js+++ b/src/services/tree.js@@ -6,7 +6,7 @@ const repository = require('./repository');const Branch = require('../entities/branch');const entityChangesService = require('./entity_changes.js');const protectedSessionService = require('./protected_session');-const noteCache = require('./note_cache/note_cache');+const becca = require('./note_cache/note_cache');function getNotes(noteIds) {// we return also deleted notes which have been specifically asked for@@ -140,11 +140,11 @@ function sortNotesByTitle(parentNoteId, foldersFirst = false, reverse = false) {sql.execute("UPDATE branches SET notePosition = ? WHERE branchId = ?",[position, note.branchId]);- if (note.branchId in noteCache.branches) {- noteCache.branches[note.branchId].notePosition = position;+ if (note.branchId in becca.branches) {+ becca.branches[note.branchId].notePosition = position;}else {- log.info(`Branch "${note.branchId}" was not found in note cache.`);+ log.info(`Branch "${note.branchId}" was not found in becca.`);}position += 10;@@ -172,7 +172,7 @@ function sortNotes(parentNoteId, sortBy, reverse = false) {sql.execute("UPDATE branches SET notePosition = ? WHERE branchId = ?",[position, branch.branchId]);- noteCache.branches[branch.branchId].notePosition = position;+ becca.branches[branch.branchId].notePosition = position;position += 10;}