Skip to content

Commit

Permalink
Add Comments stream
Browse files Browse the repository at this point in the history
  • Loading branch information
wadevries committed Sep 18, 2023
1 parent 907e5c7 commit 52356f6
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
57 changes: 57 additions & 0 deletions tap_linear/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

class CyclesStream(LinearStream):
"""Cycle stream."""

name = "cycles"
schema = th.PropertiesList(
th.Property("id", th.StringType),
Expand Down Expand Up @@ -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
}
}
}
"""
1 change: 1 addition & 0 deletions tap_linear/tap.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def discover_streams(self) -> list[streams.LinearStream]:
"""
return [
streams.CyclesStream(self),
streams.CommentStream(self),
]


Expand Down

0 comments on commit 52356f6

Please sign in to comment.