note map refactoring

This commit is contained in:
zadam
2021-09-20 23:04:41 +02:00
parent e4ba7d65e8
commit 476b8250c9
7 changed files with 40 additions and 20 deletions

View File

@@ -101,11 +101,12 @@ function buildDescendantCountMap() {
return noteIdToCountMap;
}
function getGlobalLinkMap() {
function getGlobalLinkMap(req) {
const mapRootNote = becca.getNote(req.params.noteId);
const noteIds = new Set();
const notes = Object.values(becca.notes)
.filter(note => !note.isArchived)
const notes = mapRootNote.getSubtreeNotes(false)
.map(note => [
note.noteId,
note.isContentAvailable() ? note.title : '[protected]',
@@ -144,11 +145,12 @@ function getGlobalLinkMap() {
};
}
function getGlobalTreeMap() {
function getGlobalTreeMap(req) {
const mapRootNote = becca.getNote(req.params.noteId);
const noteIds = new Set();
const notes = Object.values(becca.notes)
.filter(note => !note.isArchived && !note.hasLabel('excludeFromTreeMap'))
const notes = mapRootNote.getSubtreeNotes(false)
.filter(note => !note.hasLabel('excludeFromTreeMap'))
.map(note => [
note.noteId,
note.isContentAvailable() ? note.title : '[protected]',

View File

@@ -221,8 +221,8 @@ function register(app) {
apiRoute(GET, '/api/attributes/values/:attributeName', attributesRoute.getValuesForAttribute);
apiRoute(POST, '/api/notes/:noteId/link-map', linkMapRoute.getLinkMap);
apiRoute(POST, '/api/note-map/tree', linkMapRoute.getGlobalTreeMap);
apiRoute(POST, '/api/note-map/link', linkMapRoute.getGlobalLinkMap);
apiRoute(POST, '/api/note-map/:noteId/tree', linkMapRoute.getGlobalTreeMap);
apiRoute(POST, '/api/note-map/:noteId/link', linkMapRoute.getGlobalLinkMap);
apiRoute(GET, '/api/special-notes/inbox/:date', specialNotesRoute.getInboxNote);
apiRoute(GET, '/api/special-notes/date/:date', specialNotesRoute.getDateNote);