Skip to content

Commit

Permalink
added extra query to allow seaches of the Inbox at the same time as t…
Browse files Browse the repository at this point in the history
…asks in the Library
  • Loading branch information
rhydlewis committed Dec 13, 2016
1 parent 0e9dc1a commit 270607b
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 4 deletions.
63 changes: 63 additions & 0 deletions info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,19 @@
<false/>
</dict>
</array>
<key>9AE65283-7430-42F9-9DE5-7331FB4ACF49</key>
<array>
<dict>
<key>destinationuid</key>
<string>D43529C9-5BC5-4DCA-A1F7-9EB2E48F2E68</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
<key>AEA7E1B6-D264-4723-ABE3-9A224C6232E0</key>
<array>
<dict>
Expand Down Expand Up @@ -549,6 +562,49 @@
<key>version</key>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>alfredfiltersresults</key>
<false/>
<key>argumenttype</key>
<integer>0</integer>
<key>escaping</key>
<integer>102</integer>
<key>keyword</key>
<string>.se</string>
<key>queuedelaycustom</key>
<integer>3</integer>
<key>queuedelayimmediatelyinitially</key>
<false/>
<key>queuedelaymode</key>
<integer>1</integer>
<key>queuemode</key>
<integer>1</integer>
<key>runningsubtext</key>
<string>Searching...</string>
<key>script</key>
<string>/usr/bin/python search.py -e "{query}"</string>
<key>scriptargtype</key>
<integer>0</integer>
<key>scriptfile</key>
<string></string>
<key>subtext</key>
<string>Search OmniFocus for "{query}"</string>
<key>title</key>
<string>Search OmniFocus for processed and inbox tasks</string>
<key>type</key>
<integer>0</integer>
<key>withspace</key>
<true/>
</dict>
<key>type</key>
<string>alfred.workflow.input.scriptfilter</string>
<key>uid</key>
<string>9AE65283-7430-42F9-9DE5-7331FB4ACF49</string>
<key>version</key>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
<dict>
Expand Down Expand Up @@ -1282,6 +1338,13 @@ Well, I want it because I can't quickly search for, say, a task within OmniFocus
<key>ypos</key>
<integer>560</integer>
</dict>
<key>9AE65283-7430-42F9-9DE5-7331FB4ACF49</key>
<dict>
<key>xpos</key>
<integer>120</integer>
<key>ypos</key>
<integer>200</integer>
</dict>
<key>AEA7E1B6-D264-4723-ABE3-9A224C6232E0</key>
<dict>
<key>xpos</key>
Expand Down
8 changes: 5 additions & 3 deletions queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
TASK_FROM = ("((task tt left join projectinfo pi on tt.containingprojectinfo=pi.pk) t left join "
"task p on t.task=p.persistentIdentifier) left join "
"context c on t.context = c.persistentIdentifier")
TASK_WHERE = ("(t.effectiveInInbox = 0 AND t.inInbox = 0) AND "
"t.containingProjectInfo <> t.persistentIdentifier ")
TASK_WHERE = "(t.containingProjectInfo <> t.persistentIdentifier OR t.containingProjectInfo is NULL) "
TASK_NAME_WHERE = "t.dateCompleted IS NULL AND lower(t.name) LIKE lower('%{0}%') AND "
ACTIVE_CLAUSE = "t.blocked = 0 AND "
CTX_SELECT = "persistentIdentifier, name, allowsNextAction, active, availableTaskCount"


def search_tasks(active_only, flagged, query):
def search_tasks(active_only, flagged, query, everything=None):
where = (TASK_NAME_WHERE + TASK_WHERE).format(query)

if active_only:
Expand All @@ -24,6 +23,9 @@ def search_tasks(active_only, flagged, query):
if flagged:
where = "(t.flagged = 1 OR t.effectiveFlagged = 1) AND " + where

if not everything:
where = "(t.effectiveInInbox = 0 AND t.inInbox = 0) AND " + where

return _generate_query(TASK_SELECT, TASK_FROM, where, "t." + NAME_SORT)


Expand Down
6 changes: 5 additions & 1 deletion search.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ def populate_query(args):

active_only = args.active_only
flagged_only = args.flagged_only
everything = args.everything

if args.type == PROJECT:
log.debug('Searching projects')
sql = queries.search_projects(active_only, query)
Expand All @@ -132,7 +134,7 @@ def populate_query(args):
sql = queries.show_recent_tasks(active_only)
else:
log.debug('Searching tasks')
sql = queries.search_tasks(active_only, flagged_only, query)
sql = queries.search_tasks(active_only, flagged_only, query, everything)
return sql


Expand All @@ -142,6 +144,8 @@ def parse_args():
help='search for active tasks only')
parser.add_argument('-g', '--flagged-only', action='store_true',
help='search for flagged tasks only')
parser.add_argument('-e', '--everything', action='store_true',
help='search for tasks in the inbox as well as processed tasks')
parser.add_argument('-t', '--type', default=TASK,
choices=[INBOX, TASK, PROJECT, CONTEXT, PERSPECTIVE, FOLDER, NOTES, RECENT],
type=str, help='What to search for: (b)oth tasks and projects, (t)ask, '
Expand Down

0 comments on commit 270607b

Please sign in to comment.