From 3aed9194e9c89ace77eed5d118cd67b3fce500e5 Mon Sep 17 00:00:00 2001 From: Wouter de Vries Date: Tue, 19 Sep 2023 21:05:49 +0200 Subject: [PATCH] Add users stream --- tap_linear/streams.py | 45 +++++++++++++++++++++++++++++++++++++++++++ tap_linear/tap.py | 1 + 2 files changed, 46 insertions(+) diff --git a/tap_linear/streams.py b/tap_linear/streams.py index 9f9c5a1..093c205 100644 --- a/tap_linear/streams.py +++ b/tap_linear/streams.py @@ -298,3 +298,48 @@ class CommentStream(LinearStream): } } """ + + +class UsersStream(LinearStream): + """Users stream.""" + + name = "users" + schema = th.PropertiesList( + th.Property("id", th.StringType), + th.Property("active", th.BooleanType), + th.Property("createdAt", th.DateTimeType), + th.Property("updatedAt", th.DateTimeType), + th.Property("displayName", th.StringType), + th.Property("email", th.StringType), + th.Property("guest", th.BooleanType), + th.Property("lastSeen", th.DateTimeType), + th.Property("name", th.StringType), + ).to_dict() + + primary_keys: t.ClassVar[list[str]] = ["id"] + replication_key = "updatedAt" + query = """ + query Users($next: String, $replicationKeyValue: DateTime) { + users( + first: 100 + after: $next + filter: { updatedAt: { gt: $replicationKeyValue } } + ) { + nodes { + id + active + createdAt + updatedAt + displayName + email + guest + lastSeen + name + } + pageInfo { + hasNextPage + endCursor + } + } + } + """ diff --git a/tap_linear/tap.py b/tap_linear/tap.py index bfe0675..9697daf 100644 --- a/tap_linear/tap.py +++ b/tap_linear/tap.py @@ -46,6 +46,7 @@ def discover_streams(self) -> list[streams.LinearStream]: streams.CyclesStream(self), streams.IssuesStream(self), streams.CommentStream(self), + streams.UsersStream(self), ]