Skip to content

Instantly share code, notes, and snippets.

@pedramamini
Created June 5, 2024 05:21
Show Gist options
  • Save pedramamini/7daa30a9f839649452643b26bb784ce9 to your computer and use it in GitHub Desktop.
Save pedramamini/7daa30a9f839649452643b26bb784ce9 to your computer and use it in GitHub Desktop.
const ignoreFolders = ["YouTube"];
const ignoreContent = "Watched"; // Define the content to ignore

const results = dv.pages(`"/"`)
  .file.tasks
  .where(task => !ignoreFolders.includes(task.path.split("/")[0]) && !task.text.includes(ignoreContent));
const tasks = [...results].flat();

const completedTasks = tasks.filter(task => task.completed);
const incompleteTasks = tasks.filter(task => !task.completed);
const totalTasks = tasks.length;
const completedCount = completedTasks.length;
const progressPercentage = (completedCount / totalTasks) * 100;

const progressBar = `
  <div style="background-color: lightgray; border-radius: 8px; padding: 2px;">
    <div style="width: ${progressPercentage}%; background-color: purple; text-align: center; color: white; border-radius: 5px;">
      ${progressPercentage.toFixed(0)}%
    </div>
  </div>
`;

if (progressPercentage < 100) { dv.paragraph(progressBar) };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment