Guest
2011-06-28, 12:15 AM
Something like the following ?
(Note that AppStore-purchased copies of OmniFocus won't be able to run this without
modification)
Code:
-- Sorts Flagged and Due Soon tasks by Due Date
-- and lists tasks, with due dates, under project headings
property MaxProjChars : 15
property pstrDBPath : "~/Library/Caches/com.omnigroup.OmniFocus/OmniFocusDatabase2"
property pDelim : "~|~"
on run
set lstLines to paragraphs of (do shell script "sqlite3 -separator " & quoted form of pDelim & space & pstrDBPath & space & quoted form of ¬
"SELECT proj.name, tsk.name, tsk.effectiveFlagged, strftime('%m/%d/%Y', tsk.effectivedateDue + strftime('%s','2001-01-01'), 'unixepoch')
FROM (task t left join projectinfo p on t.containingprojectinfo=p.pk) tsk join task proj on proj.projectinfo=tsk.pk
WHERE (folderEffectiveActive is null or folderEffectiveActive = 1) and (status is null or status = \"active\")
and tsk.dateCompleted is null and tsk.blocked=0 and (tsk.isDueSoon=1 or tsk.effectiveFlagged=1)
ORDER BY tsk.effectiveFlagged DESC, tsk.effectivedateDue, proj.name")
set {lstTasks, strLastProj} to {{}, ""}
set {strDlm, text item delimiters} to {text item delimiters, pDelim}
repeat with oLine in lstLines
set {strProj, strTask, strFlagged, strDue} to text items of oLine
if strProj ≠ strLastProj then
set end of lstTasks to do shell script "echo " & quoted form of strProj & " | tr '[:lower:]' '[:upper:]'"
set strLastProj to strProj
end if
if strFlagged ≠ "0" then
set strFlag to "(!!) "
else
set strFlag to ""
end if
if strDue ≠ "" then set strDue to "(" & strDue & ") "
set end of lstTasks to "[" & Truncate(strProj) & "]: " & strTask & space & strDue & strFlag
end repeat
set text item delimiters to strDlm
return lstTasks
end run
on Truncate(strLong)
if length of strLong > MaxProjChars then
return text 1 thru MaxProjChars of strLong
else
return strLong
end if
end Truncate
Last edited by RobTrew; 2011-06-28 at 12:24 AM..