From f132f40f6bcf7adb8243717e2c8e01db65d24fbb Mon Sep 17 00:00:00 2001 From: "Aaron (\"AJ\") Steers" Date: Mon, 7 Mar 2022 10:11:03 -0800 Subject: [PATCH] workaround and TODOs for random issues --- tap_gitlab/streams.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tap_gitlab/streams.py b/tap_gitlab/streams.py index 9bb4575..1157e6a 100644 --- a/tap_gitlab/streams.py +++ b/tap_gitlab/streams.py @@ -26,6 +26,13 @@ def post_process(self, row: dict, context: Optional[dict] = None) -> Optional[di result["owner_id"] = pop_nested_id(result, "owner") return result + def get_child_context(self, record: dict, context: Optional[dict]) -> dict: + assert context is not None + return { + "project_id": record["id"], + "project_path": context["project_path"], + } + class IssuesStream(ProjectBasedStream): """Gitlab Issues stream.""" @@ -102,6 +109,20 @@ class BranchesStream(ProjectBasedStream): name = "branches" path = "/projects/{project_path}/repository/branches" primary_keys = ["project_id", "name"] + # TODO: Research why this fails: + # parent_stream_type = ProjectsStream + + def post_process(self, row: dict, context: Optional[dict] = None) -> Optional[dict]: + result = super().post_process(row, context) + if result is None: + return None + + assert context is not None + + # TODO: Uncomment when parent relationship works + # result["project_id"] = context["project_id"] + result["commit_id"] = pop_nested_id(result, "commit") + return result class PipelinesStream(ProjectBasedStream):