<%* const dv = app.plugins.plugins["dataview"].api; const openPublishPanel = app.commands.commands["publish:view-changes"].callback; const fileAndQuery = new Map([ // Meta [ "Index of all notes (alphabetical, table)", 'TABLE WITHOUT ID file.link AS Note, description AS Description FROM "notes" SORT file.link ASC' ], [ "Index of all notes (alphabetical, list)", 'LIST WITHOUT ID rows.file.link FROM "notes" GROUP BY upper(substring(file.name, 0, 1)) AS letter SORT letter ASC' ], [ "Index of all notes by tag", 'LIST rows.file.link FROM "notes" FLATTEN file.etags AS tags GROUP BY join(list("**", substring(tags, 1, length(tags)), "**"), "")' ], [ "Index of all tags (alpha sort)", 'TABLE length(rows.file.name) AS Notes FROM "notes" FLATTEN file.etags AS Tags GROUP BY Tags' ], [ "Index of all tags (count sort)", 'TABLE length(rows.file.name) AS Notes FROM "notes" FLATTEN file.etags AS Tags GROUP BY Tags SORT length(rows.file.name) DESC' ], [ "Index of original notes", 'LIST WITHOUT ID file.link FROM "notes" WHERE original = true SORT file.link ASC' ], [ "Index of random notes", 'LIST WITHOUT ID file.link FROM "notes" FLATTEN date(now) as Now FLATTEN (file.mtime.year + file.mtime.hour + file.mtime.day + file.mtime.hour + file.mtime.minute + file.mtime.second + file.size + Now.hour + Now.minute + Now.second) * 15485863 as Hash FLATTEN ((Hash * Hash * Hash) % 2038074743) / 2038074743 as Rand WHERE max(Rand) SORT Rand LIMIT 5' ], [ "Index of recent notes", 'LIST WITHOUT ID join(list(file.link, dateformat(file.mtime,"yyyy-MM-dd")), " (") + ")" FROM "notes" SORT file.ctime DESC LIMIT 5' ], //Thematic [ "Index of notes about business models", 'TABLE WITHOUT ID file.link AS Note, description AS Description FROM "notes" AND #Business/Management SORT file.link ASC' ], [ "Index of notes about cognitive biases", 'TABLE WITHOUT ID file.link AS Note, description AS Description FROM "notes" AND #Psychology/Cognitive/Bias SORT file.link ASC' ], [ "Index of notes about emotions", 'TABLE WITHOUT ID file.link AS Note, description AS Description FROM "notes" AND #Psychology/Emotions SORT file.link ASC' ], [ "Index of notes about heuristics", 'TABLE WITHOUT ID file.link AS Note, description AS Description FROM "notes" AND #Model/Heuristic SORT file.link ASC' ], [ "Index of notes about linguistics", 'TABLE WITHOUT ID file.link AS Note, description AS Description FROM "notes" AND #Linguistics SORT file.link ASC' ], [ "Index of notes about logical fallacies", 'TABLE WITHOUT ID file.link AS Note, description AS Description FROM "notes" AND #Logic/Fallacy SORT file.link ASC' ], [ "Index of notes about mathematics", 'TABLE WITHOUT ID file.link AS Note, description AS Description FROM "notes" AND #Mathematics SORT file.link ASC' ], [ "Index of notes about parables", 'TABLE WITHOUT ID file.link AS Note, description AS Description FROM "notes" AND #Model/Parable SORT file.link ASC' ], [ "Index of notes about paradoxes", 'TABLE WITHOUT ID file.link AS Note, description AS Description FROM "notes" AND #Logic/Paradox SORT file.link ASC' ], [ "Index of notes about theology", 'TABLE WITHOUT ID file.link AS Note, description AS Description FROM "notes" AND #Theology SORT file.link ASC' ] ]); await fileAndQuery.forEach(async (query, filename) => { if (!tp.file.find_tfile(filename)) { await tp.file.create_new("", filename); new Notice(`Created ${filename}.`); } const tFile = tp.file.find_tfile(filename); const queryOutput = await dv.queryMarkdown(query); const fileContent = `${queryOutput.value}`; try { await app.vault.modify(tFile, fileContent); new Notice(`Updated ${tFile.basename}.`); } catch (error) { new Notice("⚠️ ERROR updating! Check console. Skipped file: " + filename , 0); } }); openPublishPanel(); %>