Skip to content

Commit d7b9f56

Browse files
linbugpre-commit-ci[bot]edgarrmondragon
authored
feat: Add ReviewCommentReactions stream (#480)
Add a new `ReviewCommentReactionsStream` that we need. This PR was created with the help of @TrishGillett. Followed similar pattern from #407 --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Edgar Ramírez Mondragón <edgarrm358@gmail.com>
1 parent 791270d commit d7b9f56

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

tap_github/repository_streams.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,6 +1672,49 @@ class ReviewCommentsStream(GitHubRestStream):
16721672
th.Property("side", th.StringType),
16731673
).to_dict()
16741674

1675+
def get_child_context(self, record: dict, context: Context | None) -> dict:
1676+
return {
1677+
"org": context["org"] if context else None,
1678+
"repo": context["repo"] if context else None,
1679+
"repo_id": context["repo_id"] if context else None,
1680+
"comment_id": record["id"] if context else None,
1681+
"comment_url": record["html_url"] if context else None,
1682+
}
1683+
1684+
1685+
class ReviewCommentReactionsStream(GitHubRestStream):
1686+
name = "review_comment_reactions"
1687+
path = "/repos/{org}/{repo}/pulls/comments/{comment_id}/reactions"
1688+
primary_keys: ClassVar[list[str]] = ["id"]
1689+
replication_key = "created_at"
1690+
parent_stream_type = ReviewCommentsStream
1691+
ignore_parent_replication_key = False
1692+
state_partitioning_keys: ClassVar[list[str]] = ["repo", "org"]
1693+
1694+
def post_process(self, row: dict, context: Context | None = None) -> dict:
1695+
row = super().post_process(row, context)
1696+
1697+
if context:
1698+
row["comment_id"] = context.get("comment_id")
1699+
row["comment_url"] = context.get("comment_url")
1700+
1701+
return row
1702+
1703+
schema = th.PropertiesList(
1704+
# Parent keys
1705+
th.Property("org", th.StringType),
1706+
th.Property("repo", th.StringType),
1707+
th.Property("repo_id", th.IntegerType),
1708+
th.Property("comment_id", th.IntegerType),
1709+
th.Property("comment_url", th.StringType),
1710+
# Reaction properties
1711+
th.Property("id", th.IntegerType),
1712+
th.Property("node_id", th.StringType),
1713+
th.Property("user", user_object),
1714+
th.Property("content", th.StringType),
1715+
th.Property("created_at", th.DateTimeType),
1716+
).to_dict()
1717+
16751718

16761719
class ContributorsStream(GitHubRestStream):
16771720
"""Defines 'Contributors' stream. Fetching User & Bot contributors."""

tap_github/streams.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
ReadmeStream,
4949
ReleasesStream,
5050
RepositoryStream,
51+
ReviewCommentReactionsStream,
5152
ReviewCommentsStream,
5253
ReviewsStream,
5354
StargazersGraphqlStream,
@@ -116,6 +117,7 @@ def __init__(self, valid_queries: set[str], streams: list[type[Stream]]) -> None
116117
ReleasesStream,
117118
ExtraMetricsStream,
118119
RepositoryStream,
120+
ReviewCommentReactionsStream,
119121
ReviewCommentsStream,
120122
ReviewsStream,
121123
StargazersGraphqlStream,

0 commit comments

Comments
 (0)