Skip to content

Commit 8b28853

Browse files
Merge pull request #33 from mikez/main
Consistency update: Rename `due` to `deadline`, rename `checklist item` to `checklist-item`.
2 parents 92ad915 + a90e813 commit 8b28853

File tree

4 files changed

+26
-22
lines changed

4 files changed

+26
-22
lines changed

tests/test_things.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ class ThingsCase(unittest.TestCase):
1616

1717
def test_search(self):
1818
"""Test search."""
19-
tasks = things.search('wrong_query', **FILEPATH)
19+
tasks = things.search("wrong_query", **FILEPATH)
2020
self.assertEqual(0, len(tasks))
21-
tasks = things.search('To-Do % Heading', **FILEPATH)
21+
tasks = things.search("To-Do % Heading", **FILEPATH)
2222
self.assertEqual(1, len(tasks))
2323

2424
def test_inbox(self):
@@ -31,9 +31,9 @@ def test_upcoming(self):
3131
tasks = things.upcoming(**FILEPATH)
3232
self.assertEqual(2, len(tasks))
3333

34-
def test_due(self):
35-
"""Test due."""
36-
tasks = things.due(**FILEPATH)
34+
def test_deadlines(self):
35+
"""Test deadlines."""
36+
tasks = things.deadlines(**FILEPATH)
3737
self.assertEqual(1, len(tasks))
3838

3939
def test_today(self):

things/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
areas,
66
canceled,
77
completed,
8-
due,
8+
deadlines,
99
get,
1010
inbox,
1111
link,

things/api.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ def tasks(uuid=None, include_items=False, **kwargs): # noqa: C901
8585
If the argument is `True`, only include tasks _with_ a start date.
8686
If the argument is `None` (default), then include all tasks.
8787
88-
due_date : bool or None, optional
89-
If the argument is `False`, only include tasks _without_ a due date.
90-
If the argument is `True`, only include tasks _with_ a due date.
88+
deadline : bool or None, optional
89+
If the argument is `False`, only include tasks _without_ a deadline.
90+
If the argument is `True`, only include tasks _with_ a deadline.
9191
If the argument is `None` (default), then include all tasks.
9292
9393
search_query : str, optional
@@ -427,8 +427,8 @@ def today(**kwargs):
427427

428428
def upcoming(**kwargs):
429429
"""
430-
Note: unscheduled tasks with a due date are not included here.
431-
See the `due` function instead.
430+
Note: unscheduled tasks with a deadline are not included here.
431+
See the `deadline` function instead.
432432
"""
433433
return tasks(start_date=True, start="Someday", **kwargs)
434434

@@ -466,9 +466,9 @@ def completed(**kwargs):
466466
return tasks(status="completed", **kwargs)
467467

468468

469-
def due(**kwargs):
470-
result = tasks(due_date=True, **kwargs)
471-
result.sort(key=lambda task: task["due_date"])
469+
def deadlines(**kwargs):
470+
result = tasks(deadline=True, **kwargs)
471+
result.sort(key=lambda task: task["deadline"])
472472
return result
473473

474474

things/database.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

4-
"""Simple read-only API for Things."""
4+
"""Simple read-only API for Things.
5+
6+
We attempt to follow the names used in the Things app, URL Scheme,
7+
and SQL database whenever possible.
8+
"""
59

610
from __future__ import print_function
711

@@ -67,15 +71,15 @@ class Database:
6771
TABLE_META = "Meta"
6872
DATE_CREATE = "creationDate"
6973
DATE_MOD = "userModificationDate"
70-
DATE_DUE = "dueDate"
74+
DATE_DEADLINE = "dueDate"
7175
DATE_START = "startDate"
7276
DATE_STOP = "stopDate"
7377
IS_INBOX = START_TO_FILTER["Inbox"]
7478
IS_ANYTIME = START_TO_FILTER["Anytime"]
7579
IS_SOMEDAY = START_TO_FILTER["Someday"]
7680
IS_SCHEDULED = f"{DATE_START} IS NOT NULL"
7781
IS_NOT_SCHEDULED = f"{DATE_START} IS NULL"
78-
IS_DUE = f"{DATE_DUE} IS NOT NULL"
82+
IS_DEADLINE = f"{DATE_DEADLINE} IS NOT NULL"
7983
IS_RECURRING = "recurrenceRule IS NOT NULL"
8084
IS_NOT_RECURRING = "recurrenceRule IS NULL"
8185
IS_TODO = TYPE_TO_FILTER["to-do"]
@@ -120,7 +124,7 @@ def get_tasks(
120124
heading=None,
121125
tag=None,
122126
start_date=None,
123-
due_date=None,
127+
deadline=None,
124128
index="index",
125129
count_only=False,
126130
search_query=None,
@@ -168,7 +172,7 @@ def get_tasks(
168172
{make_filter("TASK.project", project)}
169173
{make_filter("TASK.actionGroup", heading)}
170174
{make_filter("TASK.startDate", start_date)}
171-
{make_filter("TASK.dueDate", due_date)}
175+
{make_filter(f"TASK.{self.DATE_DEADLINE}", deadline)}
172176
{make_filter("TAG.title", tag)}
173177
{make_search_filter(search_query)}
174178
ORDER BY TASK."{index}"
@@ -221,8 +225,8 @@ def make_task_sql_query(self, where_predicate):
221225
WHEN CHECKLIST_ITEM.uuid IS NOT NULL THEN 1
222226
END AS checklist,
223227
date(TASK.startDate, "unixepoch") AS start_date,
224-
date(TASK.dueDate, "unixepoch") AS due_date,
225-
date(TASK.stopDate, "unixepoch") AS stop_date,
228+
date(TASK.{self.DATE_DEADLINE}, "unixepoch") AS deadline,
229+
date(TASK.stopDate, "unixepoch") AS "stop_date",
226230
datetime(TASK.{self.DATE_CREATE}, "unixepoch", "localtime") AS created,
227231
datetime(TASK.{self.DATE_MOD}, "unixepoch", "localtime") AS modified
228232
FROM
@@ -302,7 +306,7 @@ def get_checklist_items(self, task_uuid=None):
302306
WHEN CHECKLIST_ITEM.{self.IS_CANCELED} THEN 'canceled'
303307
END AS status,
304308
date(CHECKLIST_ITEM.stopDate, "unixepoch") AS stop_date,
305-
'checklist item' as type,
309+
'checklist-item' as type,
306310
CHECKLIST_ITEM.uuid,
307311
datetime(
308312
CHECKLIST_ITEM.{self.DATE_MOD}, "unixepoch", "localtime"

0 commit comments

Comments
 (0)