Skip to content

Instantly share code, notes, and snippets.

@openfirmware
Created September 26, 2013 20:37
Show Gist options
  • Select an option

  • Save openfirmware/6720175 to your computer and use it in GitHub Desktop.

Select an option

Save openfirmware/6720175 to your computer and use it in GitHub Desktop.
With OmniFocus running, will log how many tasks in each context were marked completed in the last 7 days.
(*
This script logs the number of tasks completed for each context in the last 7 days.
Copyright © 2013, James Badger.
*)
property daysLimit : 7
on run
tell application "OmniFocus"
tell front document
set allContexts to every context
repeat with aContext in allContexts
log name of aContext as string
set complete_count to 0
set theTasks to tasks of aContext
repeat with aTask in theTasks
if aTask is completed and my differenceInDays(current date, completion date of aTask) is less than daysLimit then
set complete_count to complete_count + 1
end if
end repeat
log complete_count
end repeat
end tell
end tell
end run
on differenceInDays(first_date, second_date)
return (first_date - second_date) / (3600 * 24)
end differenceInDays
(*Errands*)
(*2*)
(*Home*)
(*16*)
(*Waiting*)
(*0*)
(*Work*)
(*5*)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment