Skip to content
Snippets Groups Projects
Unverified Commit 98a7aac7 authored by youngcw's avatar youngcw Committed by GitHub
Browse files

add schedule name check to check templates (#2667)

* check schedule name

* note
parent d49f907f
No related branches found
No related tags found
No related merge requests found
...@@ -641,17 +641,33 @@ async function checkTemplates(): Promise<Notification> { ...@@ -641,17 +641,33 @@ async function checkTemplates(): Promise<Notification> {
const categories = await db.all( const categories = await db.all(
'SELECT * FROM v_categories WHERE tombstone = 0', 'SELECT * FROM v_categories WHERE tombstone = 0',
); );
let all_schedule_names = await db.all(
'SELECT name from schedules WHERE name NOT NULL AND tombstone = 0',
);
all_schedule_names = all_schedule_names.map(v => v.name);
// run through each line and see if its an error // run through each line and see if its an error
for (let c = 0; c < categories.length; c++) { for (let c = 0; c < categories.length; c++) {
const category = categories[c]; const category = categories[c];
const template = category_templates[category.id]; const template = category_templates[category.id];
if (template) { if (template) {
for (let l = 0; l < template.length; l++) { for (let l = 0; l < template.length; l++) {
//check for basic error
if (template[l].type === 'error') { if (template[l].type === 'error') {
//return { type: 'message', message: "found a bad one",};
errors.push(category.name + ': ' + template[l].line); errors.push(category.name + ': ' + template[l].line);
} }
// check schedule name error
if (template[l].type === 'schedule') {
if (!all_schedule_names.includes(template[l].name)) {
errors.push(
category.name +
': Schedule “' +
template[l].name +
'” does not exist',
);
}
}
} }
} }
} }
......
---
category: Enhancements
authors: [youngcw]
---
Check schedule name when using the check templates function
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment