Skip to content

Build your personal knowledge base with Trilium Notes

fix label => attributes omissions

azivner7ac109e7f786
diff --git a/src/public/javascripts/services/note_detail_file.js b/src/public/javascripts/services/note_detail_file.js
index 6176538f21..9dab36d473 100644
--- a/src/public/javascripts/services/note_detail_file.js
+++ b/src/public/javascripts/services/note_detail_file.js
@@ -14,13 +14,13 @@ const $fileOpen = $("#file-open");
async function show() {
const currentNote = noteDetailService.getCurrentNote();
- const labels = await server.get('notes/' + currentNote.noteId + '/labels');
- const labelMap = utils.toObject(labels, l => [l.name, l.value]);
+ const attributes = await server.get('notes/' + currentNote.noteId + '/attributes');
+ const attributeMap = utils.toObject(attributes, l => [l.name, l.value]);
$noteDetailFile.show();
- $fileFileName.text(labelMap.original_file_name);
- $fileFileSize.text(labelMap.file_size + " bytes");
+ $fileFileName.text(attributeMap.original_file_name);
+ $fileFileSize.text(attributeMap.file_size + " bytes");
$fileFileType.text(currentNote.mime);
}
diff --git a/src/services/build_search_query.js b/src/services/build_search_query.js
index 84aa89f8c7..cf340ac77f 100644
--- a/src/services/build_search_query.js
+++ b/src/services/build_search_query.js
@@ -1,4 +1,4 @@
-module.exports = function(labelFilters) {
+module.exports = function(attributeFilters) {
const joins = [];
const joinParams = [];
let where = '1';
@@ -6,31 +6,31 @@ module.exports = function(labelFilters) {
let i = 1;
- for (const filter of labelFilters) {
- joins.push(`LEFT JOIN labels AS label${i} ON label${i}.noteId = notes.noteId AND label${i}.name = ?`);
+ for (const filter of attributeFilters) {
+ joins.push(`LEFT JOIN attributes AS attribute${i} ON attribute${i}.noteId = notes.noteId AND attribute${i}.name = ?`);
joinParams.push(filter.name);
where += " " + filter.relation + " ";
if (filter.operator === 'exists') {
- where += `label${i}.labelId IS NOT NULL`;
+ where += `attribute${i}.attributeId IS NOT NULL`;
}
else if (filter.operator === 'not-exists') {
- where += `label${i}.labelId IS NULL`;
+ where += `attribute${i}.attributeId IS NULL`;
}
else if (filter.operator === '=' || filter.operator === '!=') {
- where += `label${i}.value ${filter.operator} ?`;
+ where += `attribute${i}.value ${filter.operator} ?`;
whereParams.push(filter.value);
}
else if ([">", ">=", "<", "<="].includes(filter.operator)) {
const floatParam = parseFloat(filter.value);
if (isNaN(floatParam)) {
- where += `label${i}.value ${filter.operator} ?`;
+ where += `attribute${i}.value ${filter.operator} ?`;
whereParams.push(filter.value);
}
else {
- where += `CAST(label${i}.value AS DECIMAL) ${filter.operator} ?`;
+ where += `CAST(attribute${i}.value AS DECIMAL) ${filter.operator} ?`;
whereParams.push(floatParam);
}
}
diff --git a/src/services/scheduler.js b/src/services/scheduler.js
index e2f729cd9c..c671278afc 100644
--- a/src/services/scheduler.js
+++ b/src/services/scheduler.js
@@ -7,10 +7,11 @@ async function runNotesWithLabel(runAttrValue) {
const notes = await repository.getEntities(`
SELECT notes.*
FROM notes
- JOIN labels ON labels.noteId = notes.noteId
- AND labels.isDeleted = 0
- AND labels.name = 'run'
- AND labels.value = ?
+ JOIN attributes ON attributes.noteId = notes.noteId
+ AND attributes.isDeleted = 0
+ AND attributes.type = 'label'
+ AND attributes.name = 'run'
+ AND attributes.value = ?
WHERE
notes.type = 'code'
AND notes.isDeleted = 0`, [runAttrValue]);