Period:: 2024-W42 Contributor:: Jonny Week Start:: 2024-10-13 Week End:: 2024-10-19
Tasks Completed This Week
(tags include #Jonny)
done after 2024-10-13
done before 2024-10-19
short modeTasks In Progress or Targeted This Week
(tags include #Jonny)
(created before 2024-10-19) OR (starts before 2024-10-19)
not done
short modeTasks Blocked & Reasons
(tag includes #Jonny) AND (tag includes #Blocked)
(created before 2024-10-19) OR (starts before 2024-10-19)
not done
short modeTime Sheet Report
name Generate Time Sheet Report
type command
action MetaBind: Run
color blue{
"type": "js",
"id": "time-sheet-report",
"code": `
const tasks = app.plugins.plugins['obsidian-tasks-plugin'].cache.getTasks();
const contributorTag = dv.current().Contributor;
const weekStart = moment(dv.current()['Week Start']);
const weekEnd = moment(dv.current()['Week End']);
let dailyMinutes = {};
for (let i = 0; i < 7; i++) {
dailyMinutes[weekStart.clone().add(i, 'days').format('YYYY-MM-DD')] = 0;
}
tasks.forEach(task => {
if (task.tags.includes(contributorTag.slice(1)) && task.completed) {
const completionDate = moment(task.completedDate);
if (completionDate.isBetween(weekStart, weekEnd, null, '[]')) {
const timedTag = task.tags.find(tag => tag.startsWith(contributorTag.slice(1) + '/timed/'));
if (timedTag) {
const minutes = parseInt(timedTag.split('/')[2]);
const dateKey = completionDate.format('YYYY-MM-DD');
dailyMinutes[dateKey] += minutes;
}
}
}
});
let report = '## Time Sheet Report\n\n';
report += '| Date | Minutes Worked |\n';
report += '|------|----------------|\n';
let totalMinutes = 0;
Object.entries(dailyMinutes).forEach(([date, minutes]) => {
report += `| ${date} | ${minutes} |\n`;
totalMinutes += minutes;
});
report += `\nTotal minutes worked this week: ${totalMinutes}\n`;
report += `Total hours worked this week: ${(totalMinutes / 60).toFixed(2)}`;
return report;
`
}