From 52356f6eb0bf47f4a8c013c88dcd74dd79d4aec4 Mon Sep 17 00:00:00 2001 From: Wouter de Vries Date: Mon, 18 Sep 2023 09:54:15 +0200 Subject: [PATCH] Add Comments stream --- tap_linear/streams.py | 57 +++++++++++++++++++++++++++++++++++++++++++ tap_linear/tap.py | 1 + 2 files changed, 58 insertions(+) diff --git a/tap_linear/streams.py b/tap_linear/streams.py index 6ce51ca..5239b02 100644 --- a/tap_linear/streams.py +++ b/tap_linear/streams.py @@ -11,6 +11,7 @@ class CyclesStream(LinearStream): """Cycle stream.""" + name = "cycles" schema = th.PropertiesList( th.Property("id", th.StringType), @@ -80,3 +81,59 @@ class CyclesStream(LinearStream): } } """ + + +UserType = th.ObjectType( + th.Property("id", th.StringType), + th.Property("name", th.StringType), + th.Property("email", th.StringType), +) + + +class CommentStream(LinearStream): + """Comment stream.""" + + name = "comments" + schema = th.PropertiesList( + th.Property("id", th.StringType), + th.Property("createdAt", th.DateTimeType), + th.Property("updatedAt", th.DateTimeType), + th.Property("user", UserType), + th.Property( + "issue", + th.ObjectType( + th.Property("id", th.StringType), + ), + ), + ).to_dict() + + primary_keys: t.ClassVar[list[str]] = ["id"] + replication_key = "updatedAt" + query = """ + query Comments($next: String, $replicationKeyValue: DateTime) { + comments( + first: 100 + after: $next + filter: { updatedAt: { gt: $replicationKeyValue } } + ) { + nodes { + id + createdAt + updatedAt + user { + id + name + email + } + issue { + id + } + body + } + pageInfo { + hasNextPage + endCursor + } + } + } + """ diff --git a/tap_linear/tap.py b/tap_linear/tap.py index 09587fa..702b7c3 100644 --- a/tap_linear/tap.py +++ b/tap_linear/tap.py @@ -42,6 +42,7 @@ def discover_streams(self) -> list[streams.LinearStream]: """ return [ streams.CyclesStream(self), + streams.CommentStream(self), ]