The new format breaks OFQuickStats

Does anybody else out there still use Rob Trew’s Applescript OFQuickStats? I’ve been using it regularly for the last years (?) to keep track of my total number of projects and tasks.

Unfortunately, the latest OF update has broken OFQuickStats. Such is life. I’m wondering if anybody knows whether there’s a quick fix to OFQuickStats to restore the functionality or if this is the end.

If this really is the end, does anybody else have or use a script that can show the following?

  • total projects
  • total remaining projects
  • total tasks
  • total remaining tasks

I use it all the time and haven’t upgraded in part because of the problems so am also interested in a solution.

I believe this works, but I never used the original. It looked like a whole mess of SQL calls for something that can be accomplished in native AppleScript without the risk of breaking any time the database structure changes. (Unfortunately the forum eliminates white space in code or this would be a bit clearer)

[code]
global totalProjects, totalRemainingProjects, totalTasks, totalRemainingTasks
set totalProjects to 0
set totalRemainingProjects to 0
set totalTasks to 0
set totalRemainingTasks to 0

tell application “OmniFocus”
my countProjects(document 1)
return {totalProjects, totalRemainingProjects, totalTasks, totalRemainingTasks}
end tell

on countProjects(theCon)
using terms from application “OmniFocus”
tell theCon
set p to its projects
set totalProjects to totalProjects + (count of p)
repeat with theProj in p
if completed of theProj is false then
set totalRemainingProjects to totalRemainingProjects + 1
end if
set t to tasks of theProj
repeat with theTask in t
set totalTasks to totalTasks + 1
if completed of theTask is false then
set totalRemainingTasks to totalRemainingTasks + 1
end if
end repeat
end repeat
set f to its folders
repeat with aFolder in f
my countProjects(aFolder)
end repeat
end tell
end using terms from
end countProjects[/code]

So the version above actually leaves out tasks contained within tasks.
Including them increases the run time enormously (to several minutes for my 100+ projects). Now I see why Rob might have wanted to read the database directly.
Here’s a version which will include tasks within tasks, if you don’t mind the wait:

[code]
global totalProjects, totalRemainingProjects, totalTasks, totalRemainingTasks
set totalProjects to 0
set totalRemainingProjects to 0
set totalTasks to 0
set totalRemainingTasks to 0

tell application “OmniFocus”
my countProjects(document 1)
return {totalProjects, totalRemainingProjects, totalTasks, totalRemainingTasks}
end tell

on countTasks(theCon)
using terms from application “OmniFocus”
set t to tasks of theCon
repeat with theTask in t
set totalTasks to totalTasks + 1
if completed of theTask is false then
set totalRemainingTasks to totalRemainingTasks + 1
end if
my countTasks(theTask)
end repeat

end using terms from

end countTasks

on countProjects(theCon)
using terms from application “OmniFocus”
tell theCon
set p to its projects
set totalProjects to totalProjects + (count of p)
repeat with theProj in p
if completed of theProj is false then
set totalRemainingProjects to totalRemainingProjects + 1
end if
my countTasks(theProj)
end repeat
set f to its folders
repeat with aFolder in f
my countProjects(aFolder)
end repeat
end tell
end using terms from
end countProjects[/code]

Thanks!

Fortunately, though, for some reason the original OFQuickstats has been working for me again the past few weeks.