Failed to render page: SmartBlock Beta
Infinite loop on string ```javascript const daysAgo = Number(ago); if (!daysAgo) return "ERROR: You have to enter a valid number greater than 0"; const today = new Date(); const nextDate = new Date(); nextDate.setDate(today.getDate() - daysAgo); const toUid = (d) => `--`; const todayUid = toUid(today); let nextUid = toUid(nextDate); const allProjects = []; const allTasks = []; const allQuestions = []; let safety = 0; const page = client.slice(2, -2); while (nextDate['value' + 'Of']() <= today['value' + 'Of']()) { const projects = window.roamAlphaAPI .q( `[:find (pull ?project [:node/title]) (pull ?rdes [:block/string]) (pull ?rtask [:block/uid]) :where [?p :node/title "Status"] [?rr :block/refs ?pp] [?t :node/title "Date Completed"] [?d :block/uid ""] [?c :node/title "For Client"] [?cc :node/title ""] [?des :node/title "Description"] [?task :node/title "DONE"] [?r :block/refs ?d] [?r :block/refs ?t] [?rr :block/refs ?p] [?rr :block/refs ?pp] [?rdes :block/refs ?des] [?rtask :block/refs ?task] [?r :block/page ?project] [?rr :block/page ?project] [?rdes :block/page ?project] [?rtask :block/page ?project] [?cr :block/refs ?c] [?cr :block/refs ?cc] [?cr :block/page ?project] ]`).map(a => ({ title: a[0].title, description: a[1].string.slice('Description::'.length).trim(), task: a[2].uid, })); const tasks = window.roamAlphaAPI .q( `[:find (pull ?task [:block/uid]) (pull ?project [:node/title]) :where [?p :node/title "Status"] [?pp :node/title "Complete"] [?d :block/uid ""] [?dd :node/title "DONE"] [?c :node/title "For Client"] [?cc :node/title ""] [?task :block/refs ?d] [?task :block/refs ?dd] [?rr :block/refs ?p] (not [?rr :block/refs ?pp]) [?cr :block/refs ?c] [?cr :block/refs ?cc] [?task :block/page ?project] [?rr :block/page ?project] [?cr :block/page ?project] ]`).map(a => ({uid: a[0].uid, title: a[1].title})); const reducedProjects = {}; projects.forEach((p) => { if (reducedProjects[p.title]) { reducedProjects[p.title].tasks.add(p.task) } else { reducedProjects[p.title] = { title: p.title, description: p.description, tasks: new Set([p.task]), }; } }) allProjects.push(...Object.values(reducedProjects)); allTasks.push(...tasks); nextDate.setDate(nextDate.getDate() + 1); nextUid = toUid(nextDate); safety++; if (safety > 1000) { return `ERROR: Smart block timed out at over 1000 days. Was this intended or is it a bug?` } } const questions = window.roamAlphaAPI .q( `[:find (pull ?task [:block/uid]) (pull ?question [:node/title]) :where [?p :node/title "Status"] [?pp :node/title "Questions"] [?dd :node/title "TODO"] [?c :node/title "For Client"] [?cc :node/title ""] [?task :block/refs ?d] [?task :block/refs ?dd] [?rr :block/refs ?p] [?rr :block/refs ?pp] [?cr :block/refs ?c] [?cr :block/refs ?cc] [?task :block/page ?question] [?rr :block/page ?question] [?cr :block/page ?question] ]`).map(a => ({uid: a[0].uid, title: a[1].title})); allQuestions.push(...questions); console.table(questions); console.log("test"); const groupedTasks = allTasks.reduce((prev, cur) => { if (prev[cur.title]) { prev[cur.title].push(cur.uid); } else { prev[cur.title] = [cur.uid]; } return prev; }, {}); const groupedQuestions = allQuestions.reduce((prev, cur) => { if (prev[cur.title]) { prev[cur.title].push(cur.uid); } else { prev[cur.title] = [cur.uid]; } return prev; }, {}); return [{ text: `From to `, children: [], },{ text: `**Completed Projects:** heading: 2, children: allProjects.length ? allProjects.flatMap(p => [ {text: `[[]] { text: `____`, children: Array.from(p.tasks).map(uid => ({ text: `(())` })) } ]) : [{text:'No Projects completed.'}] },{ text: `**In-Progress Projects:** heading: 2, children: Object.keys(groupedTasks).length ? Object.entries(groupedTasks).map(([title, tasks]) => ({ text: `[[]] children: tasks.map((text) => ({text: `(())`})), })) : [{text:'No Tasks completed.'}] },{ text: `**Items to Review:** heading: 2, children: Object.keys(groupedQuestions).length ? Object.entries(groupedQuestions).map(([title, qs]) => ({ text: `[[]] children: qs.map((text) => ({text: `(())`})), })) : [{text:'No Questions available.'}] }]; ````%> Please report this to https://github.com/markedjs/marked.