The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniFocus > OmniFocus Extras
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Applescript to count database items Thread Tools Search this Thread Display Modes
Is there some built in function or a script somewhere that will tell me how many tasks that I have?

Or, not being an AppleScripter myself, perhaps someone could point me to a pre-written script that would count my tasks in total, complete, to do, per context, per project, per due date, etc?

It may sound odd, but there's a certain motivation and satisfaction seeing the numbers go down day per day.

Thanks for letting me know.
 
http://forums.omnigroup.com/showthread.php?t=9983 will count all items you have selected in your current view
 
It's not very sophisticated and may not provide everything you're looking for, but here's a quick script I wrote a couple months ago and posted in a different thread on this forum. I've made a few changes since then, so rather than link to that old post, here's the updated script.

Count Database Items.zip

If you have a large database, it may take a few seconds to collect the data. The script output looks like this:

Click image for larger version

Name:	Picture 1.jpg
Views:	1629
Size:	11.4 KB
ID:	820

Hope this helps.

-Dennis

Last edited by Toadling; 2008-12-16 at 10:40 AM..
 
Quote:
Originally Posted by Toadling View Post
It's not very sophisticated and may not provide everything you're looking for, but here's a quick script I wrote a couple months ago and posted in a different thread on this forum. I've made a few changes since then, so rather than link to that old post, here's the updated script.

Attachment 819

Hope this helps.

-Dennis
It sure does, thanks! And by the way, it's also a nice re-intro to apple script (we can actually declare globals and such now? Cool!)

Thanks to both of you!
 
Neat script! Thanks for putting it together. Any chance you could get some granularity on actions (ie next actions, available actions, completed actions)?

Thanks,

Randy




Quote:
Originally Posted by Toadling View Post
It's not very sophisticated and may not provide everything you're looking for, but here's a quick script I wrote a couple months ago and posted in a different thread on this forum. I've made a few changes since then, so rather than link to that old post, here's the updated script.

Attachment 819

If you have a large database, it may take a few seconds to collect the data. The script output looks like this:

Attachment 820

Hope this helps.

-Dennis
 
Quote:
Neat script! Thanks for putting it together. Any chance you could ...
Remember, Dennis, no good deed goes unpunished :-)
 
Thanks for this script. That helped already. :-)

Quote:
Originally Posted by Toadling View Post
It's not very sophisticated and may not provide everything you're looking for, but here's a quick script I wrote a couple months ago and posted in a different thread on this forum. I've made a few changes since then, so rather than link to that old post, here's the updated script.

Attachment 819

If you have a large database, it may take a few seconds to collect the data. The script output looks like this:

Attachment 820

Hope this helps.

-Dennis
 
Just a small update to the Count Database Items script. Paul (from OmniGroup) and I added support for Pending projects (projects that are active but are pending) and Current Projects which is active projects minus pending projects.

This really helps me see how much I have on my plate and I have built it into my weekly review to make sure I am under a certain amount.

BZ
Attached Thumbnails
Click image for larger version

Name:	Screen shot 2011-01-12 at 8.11.12 AM | Jan 12, 2011.jpg
Views:	512
Size:	49.7 KB
ID:	1728  
Attached Files
File Type: zip Count Database Items.scpt.zip (85.9 KB, 519 views)

Last edited by BwanaZulia; 2011-01-12 at 04:28 AM..
 
Nice work. A couple of thoughts:

Your total action count is probably not quite right - you are taking the total number of records in the task table, but a significant proportion of these records are actually projects rather than tasks.
(Of those that remain, some are actions and some are action groups. For some purposes it may be helpful to count these separately).

(For an approach which separately counts actions, action groups, and inbox actions, see, for example: Script for a Quick listing of OmniFocus Statistics

Your useful addition of a Pending statistic may also need adjusting to take account of folder status. OmniFocus does not treat projects as pending if their folder (or any ancestral folder) is dropped.

Your whose clause could therefore be expanded to something like:
((singleton action holder is false) and (status is active) and (start date > now) and ((effectively hidden of its folder is false) or (its folder is missing value)))
(See Draft FAQ: OF 1.8 Filter options and their search-language equivalents)

Finally, a small programming point which might allow some simplification and a slight gain in speed - as of Ver 1.8 we no longer need to recursively walk the object trees - you can get your stats directly by applying the where/whose conditions directly to collections such as flattened folders, or flattened projects of the default document.

Rob

--

Last edited by RobTrew; 2011-01-12 at 11:07 AM..
 
A simplified (non-recursive) framework might look like the code below

(I have also sketched a couple of the statistical amendments)

Code:
set {strDelim, text item delimiters} to {text item delimiters, return}

-- LIST YOUR LABELS AND THEIR DEFINITIONS
tell application id "com.omnigroup.omnifocus"
	tell default document
		set strResults to {¬
			"Actions, excluding action groups: " & (do shell script "sqlite3 ~/Library/Caches/com.omnigroup.OmniFocus/OmniFocusDatabase2 'select count(*) from task where (projectinfo is null) and (childrenCount=0)';"), ¬
			"", ¬
			"Active Folders: " & (count of (flattened folders where its hidden is false)) as string, ¬
			"Dropped Folders: " & (count of (flattened folders where hidden is true)) as string, ¬
			"", ¬
			"Various other categories, and their counts", ¬
			"...", ¬
			"etc.", ¬
			"", ¬
			"Pending projects: " & (count of (flattened projects where singleton action holder is false and status is active and ¬
			((its folder is missing value) or (effectively hidden of its folder is false)) and its start date > (current date))) as string ¬
			} as string
	end tell
end tell

-- AND OFFER THE RESULTS TO THE USER
display dialog strResults buttons {"Definition Cookbook", "Copy", "OK"} default button {"OK"} with title "No need for recursion ..."
set btn to button returned of result
if btn is "Copy" then
	set the clipboard to strResults
else if btn is "Definition Cookbook" then
	do shell script "open " & quoted form of "http://forums.omnigroup.com/showthread.php?p=84886#post84886"
end if

set text item delimiters to strDelim

Last edited by RobTrew; 2011-01-12 at 09:14 AM..
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Applescript to create Inbox Items from Adium RussBlaisdell OmniFocus Extras 1 2011-01-05 03:09 PM
Count of items in a perspective? RFBriggs OmniFocus 1 for Mac 0 2010-06-08 06:59 AM
Any way to tell omnifocus to compact database by applescript? pumemei OmniFocus 1 for Mac 0 2010-06-08 02:11 AM
Completed projects' un-checked items cause bad folder "remaining" count [BUG: Fixing] hardcoreUFO OmniFocus for iPhone 7 2009-08-04 03:37 PM
Help with Adjustment to Applescript: Move Checked Items winginstitute OmniOutliner 3 for Mac 0 2006-08-25 09:32 AM


All times are GMT -8. The time now is 11:13 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.