From 4d1fd87750df562ab56154ed20e6a53ab32726b9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 13 Apr 2021 16:43:28 +0000 Subject: [PATCH] Updated docs --- docs/things.html | 2 +- docs/things/database.html | 445 ++++++++++++++++---------------------- 2 files changed, 188 insertions(+), 259 deletions(-) diff --git a/docs/things.html b/docs/things.html index 757adff..f9768df 100644 --- a/docs/things.html +++ b/docs/things.html @@ -56,7 +56,7 @@

__copyright__ = "2021 Alexander Willner & Michael Belfrage" __credits__ = ["Alexander Willner", "Michael Belfrage"] __license__ = "Apache License 2.0" -__version__ = "0.0.9.dev" +__version__ = "0.0.10" __maintainer__ = ["Alexander Willner", "Michael Belfrage"] __email__ = "alex@willner.ws" __status__ = "Development" diff --git a/docs/things/database.html b/docs/things/database.html index fac4e5d..fe0d774 100644 --- a/docs/things/database.html +++ b/docs/things/database.html @@ -39,9 +39,6 @@

API Documentation

  • get_tasks
  • -
  • - make_task_sql_query -
  • get_task_rows
  • @@ -105,6 +102,9 @@

    API Documentation

    +
  • + make_tasks_sql_query +
  • dict_factory
  • @@ -367,92 +367,15 @@

    ORDER BY TASK."{index}" """ - sql_query = self.make_task_sql_query(where_predicate) + sql_query = make_tasks_sql_query(where_predicate) if count_only: return self.get_count(sql_query) return self.execute_query(sql_query) - def make_task_sql_query(self, where_predicate): - """Make SQL query for Task table""" - return f""" - SELECT DISTINCT - TASK.uuid, - CASE - WHEN TASK.{IS_TODO} THEN 'to-do' - WHEN TASK.{IS_PROJECT} THEN 'project' - WHEN TASK.{IS_HEADING} THEN 'heading' - END AS type, - CASE - WHEN TASK.{IS_TRASHED} THEN 1 - END AS trashed, - TASK.title, - CASE - WHEN TASK.{IS_INCOMPLETE} THEN 'incomplete' - WHEN TASK.{IS_COMPLETED} THEN 'completed' - WHEN TASK.{IS_CANCELED} THEN 'canceled' - END AS status, - CASE - WHEN AREA.uuid IS NOT NULL THEN AREA.uuid - END AS area, - CASE - WHEN AREA.uuid IS NOT NULL THEN AREA.title - END AS area_title, - CASE - WHEN PROJECT.uuid IS NOT NULL THEN PROJECT.uuid - END AS project, - CASE - WHEN PROJECT.uuid IS NOT NULL THEN PROJECT.title - END AS project_title, - CASE - WHEN HEADING.uuid IS NOT NULL THEN HEADING.uuid - END AS heading, - CASE - WHEN HEADING.uuid IS NOT NULL THEN HEADING.title - END AS heading_title, - TASK.notes, - CASE - WHEN TAG.uuid IS NOT NULL THEN 1 - END AS tags, - CASE - WHEN TASK.{IS_INBOX} THEN 'Inbox' - WHEN TASK.{IS_ANYTIME} THEN 'Anytime' - WHEN TASK.{IS_SOMEDAY} THEN 'Someday' - END AS start, - CASE - WHEN CHECKLIST_ITEM.uuid IS NOT NULL THEN 1 - END AS checklist, - date(TASK.startDate, "unixepoch") AS start_date, - date(TASK.{DATE_DEADLINE}, "unixepoch") AS deadline, - date(TASK.stopDate, "unixepoch") AS "stop_date", - datetime(TASK.{DATE_CREATED}, "unixepoch", "localtime") AS created, - datetime(TASK.{DATE_MODIFIED}, "unixepoch", "localtime") AS modified, - TASK.'index', - TASK.todayIndex AS today_index - FROM - {TABLE_TASK} AS TASK - LEFT OUTER JOIN - {TABLE_TASK} PROJECT ON TASK.project = PROJECT.uuid - LEFT OUTER JOIN - {TABLE_AREA} AREA ON TASK.area = AREA.uuid - LEFT OUTER JOIN - {TABLE_TASK} HEADING ON TASK.actionGroup = HEADING.uuid - LEFT OUTER JOIN - {TABLE_TASK} HEADPROJ ON HEADING.project = HEADPROJ.uuid - LEFT OUTER JOIN - {TABLE_TASKTAG} TAGS ON TASK.uuid = TAGS.tasks - LEFT OUTER JOIN - {TABLE_TAG} TAG ON TAGS.tags = TAG.uuid - LEFT OUTER JOIN - {TABLE_CHECKLIST_ITEM} CHECKLIST_ITEM - ON CHECKLIST_ITEM.task = TASK.uuid - WHERE - {where_predicate} - """ - def get_task_rows(self, where_predicate): """Executes SQL query with given WHERE predicate.""" - return self.execute_query(self.make_task_sql_query(where_predicate)) + return self.execute_query(make_tasks_sql_query(where_predicate)) def get_areas(self, uuid=None, tag=None, count_only=False): """Get areas. See `api.areas` for details on parameters.""" @@ -594,6 +517,7 @@

    plist_bytes = result[0].encode() return plistlib.loads(plist_bytes) + # pylint: disable=R1710 def get_url_scheme_auth_token(self): """Get the Things URL scheme authentication token.""" @@ -605,6 +529,7 @@

    WHERE uuid = 'RhAzEf6qDxCD5PmnZVtBZR' """ + if result := self.execute_query(sql_query, row_factory=list_factory): return result[0] @@ -837,6 +762,84 @@

    # Helper functions +def make_tasks_sql_query(where_predicate): + """Make SQL query for Task table""" + return f""" + SELECT DISTINCT + TASK.uuid, + CASE + WHEN TASK.{IS_TODO} THEN 'to-do' + WHEN TASK.{IS_PROJECT} THEN 'project' + WHEN TASK.{IS_HEADING} THEN 'heading' + END AS type, + CASE + WHEN TASK.{IS_TRASHED} THEN 1 + END AS trashed, + TASK.title, + CASE + WHEN TASK.{IS_INCOMPLETE} THEN 'incomplete' + WHEN TASK.{IS_COMPLETED} THEN 'completed' + WHEN TASK.{IS_CANCELED} THEN 'canceled' + END AS status, + CASE + WHEN AREA.uuid IS NOT NULL THEN AREA.uuid + END AS area, + CASE + WHEN AREA.uuid IS NOT NULL THEN AREA.title + END AS area_title, + CASE + WHEN PROJECT.uuid IS NOT NULL THEN PROJECT.uuid + END AS project, + CASE + WHEN PROJECT.uuid IS NOT NULL THEN PROJECT.title + END AS project_title, + CASE + WHEN HEADING.uuid IS NOT NULL THEN HEADING.uuid + END AS heading, + CASE + WHEN HEADING.uuid IS NOT NULL THEN HEADING.title + END AS heading_title, + TASK.notes, + CASE + WHEN TAG.uuid IS NOT NULL THEN 1 + END AS tags, + CASE + WHEN TASK.{IS_INBOX} THEN 'Inbox' + WHEN TASK.{IS_ANYTIME} THEN 'Anytime' + WHEN TASK.{IS_SOMEDAY} THEN 'Someday' + END AS start, + CASE + WHEN CHECKLIST_ITEM.uuid IS NOT NULL THEN 1 + END AS checklist, + date(TASK.startDate, "unixepoch") AS start_date, + date(TASK.{DATE_DEADLINE}, "unixepoch") AS deadline, + date(TASK.stopDate, "unixepoch") AS "stop_date", + datetime(TASK.{DATE_CREATED}, "unixepoch", "localtime") AS created, + datetime(TASK.{DATE_MODIFIED}, "unixepoch", "localtime") AS modified, + TASK.'index', + TASK.todayIndex AS today_index + FROM + {TABLE_TASK} AS TASK + LEFT OUTER JOIN + {TABLE_TASK} PROJECT ON TASK.project = PROJECT.uuid + LEFT OUTER JOIN + {TABLE_AREA} AREA ON TASK.area = AREA.uuid + LEFT OUTER JOIN + {TABLE_TASK} HEADING ON TASK.actionGroup = HEADING.uuid + LEFT OUTER JOIN + {TABLE_TASK} HEADPROJ ON HEADING.project = HEADPROJ.uuid + LEFT OUTER JOIN + {TABLE_TASKTAG} TAGS ON TASK.uuid = TAGS.tasks + LEFT OUTER JOIN + {TABLE_TAG} TAG ON TAGS.tags = TAG.uuid + LEFT OUTER JOIN + {TABLE_CHECKLIST_ITEM} CHECKLIST_ITEM + ON CHECKLIST_ITEM.task = TASK.uuid + WHERE + {where_predicate} + """ + + def dict_factory(cursor, row): """ Convert SQL result into a dictionary. @@ -1139,92 +1142,15 @@

    ORDER BY TASK."{index}" """ - sql_query = self.make_task_sql_query(where_predicate) + sql_query = make_tasks_sql_query(where_predicate) if count_only: return self.get_count(sql_query) return self.execute_query(sql_query) - def make_task_sql_query(self, where_predicate): - """Make SQL query for Task table""" - return f""" - SELECT DISTINCT - TASK.uuid, - CASE - WHEN TASK.{IS_TODO} THEN 'to-do' - WHEN TASK.{IS_PROJECT} THEN 'project' - WHEN TASK.{IS_HEADING} THEN 'heading' - END AS type, - CASE - WHEN TASK.{IS_TRASHED} THEN 1 - END AS trashed, - TASK.title, - CASE - WHEN TASK.{IS_INCOMPLETE} THEN 'incomplete' - WHEN TASK.{IS_COMPLETED} THEN 'completed' - WHEN TASK.{IS_CANCELED} THEN 'canceled' - END AS status, - CASE - WHEN AREA.uuid IS NOT NULL THEN AREA.uuid - END AS area, - CASE - WHEN AREA.uuid IS NOT NULL THEN AREA.title - END AS area_title, - CASE - WHEN PROJECT.uuid IS NOT NULL THEN PROJECT.uuid - END AS project, - CASE - WHEN PROJECT.uuid IS NOT NULL THEN PROJECT.title - END AS project_title, - CASE - WHEN HEADING.uuid IS NOT NULL THEN HEADING.uuid - END AS heading, - CASE - WHEN HEADING.uuid IS NOT NULL THEN HEADING.title - END AS heading_title, - TASK.notes, - CASE - WHEN TAG.uuid IS NOT NULL THEN 1 - END AS tags, - CASE - WHEN TASK.{IS_INBOX} THEN 'Inbox' - WHEN TASK.{IS_ANYTIME} THEN 'Anytime' - WHEN TASK.{IS_SOMEDAY} THEN 'Someday' - END AS start, - CASE - WHEN CHECKLIST_ITEM.uuid IS NOT NULL THEN 1 - END AS checklist, - date(TASK.startDate, "unixepoch") AS start_date, - date(TASK.{DATE_DEADLINE}, "unixepoch") AS deadline, - date(TASK.stopDate, "unixepoch") AS "stop_date", - datetime(TASK.{DATE_CREATED}, "unixepoch", "localtime") AS created, - datetime(TASK.{DATE_MODIFIED}, "unixepoch", "localtime") AS modified, - TASK.'index', - TASK.todayIndex AS today_index - FROM - {TABLE_TASK} AS TASK - LEFT OUTER JOIN - {TABLE_TASK} PROJECT ON TASK.project = PROJECT.uuid - LEFT OUTER JOIN - {TABLE_AREA} AREA ON TASK.area = AREA.uuid - LEFT OUTER JOIN - {TABLE_TASK} HEADING ON TASK.actionGroup = HEADING.uuid - LEFT OUTER JOIN - {TABLE_TASK} HEADPROJ ON HEADING.project = HEADPROJ.uuid - LEFT OUTER JOIN - {TABLE_TASKTAG} TAGS ON TASK.uuid = TAGS.tasks - LEFT OUTER JOIN - {TABLE_TAG} TAG ON TAGS.tags = TAG.uuid - LEFT OUTER JOIN - {TABLE_CHECKLIST_ITEM} CHECKLIST_ITEM - ON CHECKLIST_ITEM.task = TASK.uuid - WHERE - {where_predicate} - """ - def get_task_rows(self, where_predicate): """Executes SQL query with given WHERE predicate.""" - return self.execute_query(self.make_task_sql_query(where_predicate)) + return self.execute_query(make_tasks_sql_query(where_predicate)) def get_areas(self, uuid=None, tag=None, count_only=False): """Get areas. See `api.areas` for details on parameters.""" @@ -1366,6 +1292,7 @@

    plist_bytes = result[0].encode() return plistlib.loads(plist_bytes) + # pylint: disable=R1710 def get_url_scheme_auth_token(self): """Get the Things URL scheme authentication token.""" @@ -1377,6 +1304,7 @@

    WHERE uuid = 'RhAzEf6qDxCD5PmnZVtBZR' """ + if result := self.execute_query(sql_query, row_factory=list_factory): return result[0] @@ -1756,7 +1684,7 @@

    Parameters
    ORDER BY TASK."{index}" """ - sql_query = self.make_task_sql_query(where_predicate) + sql_query = make_tasks_sql_query(where_predicate) if count_only: return self.get_count(sql_query) @@ -1769,101 +1697,6 @@
    Parameters
    - -
    -
    #   - - - def - make_task_sql_query(self, where_predicate): -
    - -
    - View Source -
        def make_task_sql_query(self, where_predicate):
    -        """Make SQL query for Task table"""
    -        return f"""
    -            SELECT DISTINCT
    -                TASK.uuid,
    -                CASE
    -                    WHEN TASK.{IS_TODO} THEN 'to-do'
    -                    WHEN TASK.{IS_PROJECT} THEN 'project'
    -                    WHEN TASK.{IS_HEADING} THEN 'heading'
    -                END AS type,
    -                CASE
    -                    WHEN TASK.{IS_TRASHED} THEN 1
    -                END AS trashed,
    -                TASK.title,
    -                CASE
    -                    WHEN TASK.{IS_INCOMPLETE} THEN 'incomplete'
    -                    WHEN TASK.{IS_COMPLETED} THEN 'completed'
    -                    WHEN TASK.{IS_CANCELED} THEN 'canceled'
    -                END AS status,
    -                CASE
    -                    WHEN AREA.uuid IS NOT NULL THEN AREA.uuid
    -                END AS area,
    -                CASE
    -                    WHEN AREA.uuid IS NOT NULL THEN AREA.title
    -                END AS area_title,
    -                CASE
    -                    WHEN PROJECT.uuid IS NOT NULL THEN PROJECT.uuid
    -                END AS project,
    -                CASE
    -                    WHEN PROJECT.uuid IS NOT NULL THEN PROJECT.title
    -                END AS project_title,
    -                CASE
    -                    WHEN HEADING.uuid IS NOT NULL THEN HEADING.uuid
    -                END AS heading,
    -                CASE
    -                    WHEN HEADING.uuid IS NOT NULL THEN HEADING.title
    -                END AS heading_title,
    -                TASK.notes,
    -                CASE
    -                    WHEN TAG.uuid IS NOT NULL THEN 1
    -                END AS tags,
    -                CASE
    -                    WHEN TASK.{IS_INBOX} THEN 'Inbox'
    -                    WHEN TASK.{IS_ANYTIME} THEN 'Anytime'
    -                    WHEN TASK.{IS_SOMEDAY} THEN 'Someday'
    -                END AS start,
    -                CASE
    -                    WHEN CHECKLIST_ITEM.uuid IS NOT NULL THEN 1
    -                END AS checklist,
    -                date(TASK.startDate, "unixepoch") AS start_date,
    -                date(TASK.{DATE_DEADLINE}, "unixepoch") AS deadline,
    -                date(TASK.stopDate, "unixepoch") AS "stop_date",
    -                datetime(TASK.{DATE_CREATED}, "unixepoch", "localtime") AS created,
    -                datetime(TASK.{DATE_MODIFIED}, "unixepoch", "localtime") AS modified,
    -                TASK.'index',
    -                TASK.todayIndex AS today_index
    -            FROM
    -                {TABLE_TASK} AS TASK
    -            LEFT OUTER JOIN
    -                {TABLE_TASK} PROJECT ON TASK.project = PROJECT.uuid
    -            LEFT OUTER JOIN
    -                {TABLE_AREA} AREA ON TASK.area = AREA.uuid
    -            LEFT OUTER JOIN
    -                {TABLE_TASK} HEADING ON TASK.actionGroup = HEADING.uuid
    -            LEFT OUTER JOIN
    -                {TABLE_TASK} HEADPROJ ON HEADING.project = HEADPROJ.uuid
    -            LEFT OUTER JOIN
    -                {TABLE_TASKTAG} TAGS ON TASK.uuid = TAGS.tasks
    -            LEFT OUTER JOIN
    -                {TABLE_TAG} TAG ON TAGS.tags = TAG.uuid
    -            LEFT OUTER JOIN
    -                {TABLE_CHECKLIST_ITEM} CHECKLIST_ITEM
    -                ON CHECKLIST_ITEM.task = TASK.uuid
    -            WHERE
    -                {where_predicate}
    -            """
    -
    - -
    - -

    Make SQL query for Task table

    -
    - -
    #   @@ -1877,7 +1710,7 @@
    Parameters
    View Source
        def get_task_rows(self, where_predicate):
             """Executes SQL query with given WHERE predicate."""
    -        return self.execute_query(self.make_task_sql_query(where_predicate))
    +        return self.execute_query(make_tasks_sql_query(where_predicate))
     
    @@ -2156,6 +1989,7 @@
    Parameters
    WHERE uuid = 'RhAzEf6qDxCD5PmnZVtBZR' """ + if result := self.execute_query(sql_query, row_factory=list_factory): return result[0]
    @@ -2606,6 +2440,101 @@
    Parameters
    + +
    +
    #   + + + def + make_tasks_sql_query(where_predicate): +
    + +
    + View Source +
    def make_tasks_sql_query(where_predicate):
    +    """Make SQL query for Task table"""
    +    return f"""
    +            SELECT DISTINCT
    +                TASK.uuid,
    +                CASE
    +                    WHEN TASK.{IS_TODO} THEN 'to-do'
    +                    WHEN TASK.{IS_PROJECT} THEN 'project'
    +                    WHEN TASK.{IS_HEADING} THEN 'heading'
    +                END AS type,
    +                CASE
    +                    WHEN TASK.{IS_TRASHED} THEN 1
    +                END AS trashed,
    +                TASK.title,
    +                CASE
    +                    WHEN TASK.{IS_INCOMPLETE} THEN 'incomplete'
    +                    WHEN TASK.{IS_COMPLETED} THEN 'completed'
    +                    WHEN TASK.{IS_CANCELED} THEN 'canceled'
    +                END AS status,
    +                CASE
    +                    WHEN AREA.uuid IS NOT NULL THEN AREA.uuid
    +                END AS area,
    +                CASE
    +                    WHEN AREA.uuid IS NOT NULL THEN AREA.title
    +                END AS area_title,
    +                CASE
    +                    WHEN PROJECT.uuid IS NOT NULL THEN PROJECT.uuid
    +                END AS project,
    +                CASE
    +                    WHEN PROJECT.uuid IS NOT NULL THEN PROJECT.title
    +                END AS project_title,
    +                CASE
    +                    WHEN HEADING.uuid IS NOT NULL THEN HEADING.uuid
    +                END AS heading,
    +                CASE
    +                    WHEN HEADING.uuid IS NOT NULL THEN HEADING.title
    +                END AS heading_title,
    +                TASK.notes,
    +                CASE
    +                    WHEN TAG.uuid IS NOT NULL THEN 1
    +                END AS tags,
    +                CASE
    +                    WHEN TASK.{IS_INBOX} THEN 'Inbox'
    +                    WHEN TASK.{IS_ANYTIME} THEN 'Anytime'
    +                    WHEN TASK.{IS_SOMEDAY} THEN 'Someday'
    +                END AS start,
    +                CASE
    +                    WHEN CHECKLIST_ITEM.uuid IS NOT NULL THEN 1
    +                END AS checklist,
    +                date(TASK.startDate, "unixepoch") AS start_date,
    +                date(TASK.{DATE_DEADLINE}, "unixepoch") AS deadline,
    +                date(TASK.stopDate, "unixepoch") AS "stop_date",
    +                datetime(TASK.{DATE_CREATED}, "unixepoch", "localtime") AS created,
    +                datetime(TASK.{DATE_MODIFIED}, "unixepoch", "localtime") AS modified,
    +                TASK.'index',
    +                TASK.todayIndex AS today_index
    +            FROM
    +                {TABLE_TASK} AS TASK
    +            LEFT OUTER JOIN
    +                {TABLE_TASK} PROJECT ON TASK.project = PROJECT.uuid
    +            LEFT OUTER JOIN
    +                {TABLE_AREA} AREA ON TASK.area = AREA.uuid
    +            LEFT OUTER JOIN
    +                {TABLE_TASK} HEADING ON TASK.actionGroup = HEADING.uuid
    +            LEFT OUTER JOIN
    +                {TABLE_TASK} HEADPROJ ON HEADING.project = HEADPROJ.uuid
    +            LEFT OUTER JOIN
    +                {TABLE_TASKTAG} TAGS ON TASK.uuid = TAGS.tasks
    +            LEFT OUTER JOIN
    +                {TABLE_TAG} TAG ON TAGS.tags = TAG.uuid
    +            LEFT OUTER JOIN
    +                {TABLE_CHECKLIST_ITEM} CHECKLIST_ITEM
    +                ON CHECKLIST_ITEM.task = TASK.uuid
    +            WHERE
    +                {where_predicate}
    +            """
    +
    + +
    + +

    Make SQL query for Task table

    +
    + +