From 1c6fc9029f418c9f3f981afd9d8896a458f941a0 Mon Sep 17 00:00:00 2001 From: azivner Date: Sun, 4 Mar 2018 22:09:51 -0500 Subject: [PATCH] new "disable_inclusion" attribute --- src/entities/note.js | 7 +++++++ src/services/attributes.js | 3 ++- src/services/scheduler.js | 2 +- src/services/script.js | 4 ++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/entities/note.js b/src/entities/note.js index f0a18a00e..c0f758e02 100644 --- a/src/entities/note.js +++ b/src/entities/note.js @@ -47,6 +47,13 @@ class Note extends Entity { return map; } + async hasAttribute(name) { + const map = await this.getAttributeMap(); + + return map.hasOwnProperty(name); + } + + // WARNING: this doesn't take into account the possibility to have multi-valued attributes! async getAttribute(name) { return this.repository.getEntity("SELECT * FROM attributes WHERE noteId = ? AND name = ?", [this.noteId, name]); } diff --git a/src/services/attributes.js b/src/services/attributes.js index fc7269ece..8c8cc8e66 100644 --- a/src/services/attributes.js +++ b/src/services/attributes.js @@ -12,7 +12,8 @@ const BUILTIN_ATTRIBUTES = [ 'hide_in_autocomplete', 'exclude_from_export', 'run', - 'manual_transaction_handling' + 'manual_transaction_handling', + 'disable_inclusion' ]; async function getNoteAttributeMap(noteId) { diff --git a/src/services/scheduler.js b/src/services/scheduler.js index b256615eb..048501307 100644 --- a/src/services/scheduler.js +++ b/src/services/scheduler.js @@ -19,7 +19,7 @@ async function runNotesWithAttribute(runAttrValue) { } } -setTimeout(() => runNotesWithAttribute('backend_startup'), 1 * 1000); +setTimeout(() => runNotesWithAttribute('backend_startup'), 10 * 1000); setInterval(() => runNotesWithAttribute('hourly'), 3600 * 1000); diff --git a/src/services/script.js b/src/services/script.js index 78261d868..415c9454b 100644 --- a/src/services/script.js +++ b/src/services/script.js @@ -61,6 +61,10 @@ async function getScriptBundle(note, includedNoteIds = []) { return; } + if (await note.hasAttribute('disable_inclusion')) { + return; + } + const bundle = { note: note, script: '',