From 5d9edf2416dd037fd03dd404e5b8c0152a3f7d21 Mon Sep 17 00:00:00 2001 From: Nav Sha Date: Thu, 3 Mar 2022 10:18:51 +0000 Subject: [PATCH] adding repo team event --- bq-workers/github-parser/main.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bq-workers/github-parser/main.py b/bq-workers/github-parser/main.py index 1a90e51b..7623e288 100644 --- a/bq-workers/github-parser/main.py +++ b/bq-workers/github-parser/main.py @@ -86,7 +86,7 @@ def process_github_event(headers, msg): "pull_request_review_comment", "issues", "issue_comment", "check_run", "check_suite", "status", "deployment_status", "release", "deployment", - "team", "membership", "repository"} + "team", "membership", "repository", "team_add"} if event_type not in types: raise Exception("Unsupported GitHub event: '%s'" % event_type) @@ -153,13 +153,21 @@ def process_github_event(headers, msg): if event_type == "membership": # Team Membership events do not carry any create/update date, for adding new repo as well - # so adding the date of the basis of it arrives for processing. + # This event doesn't have unique id as it carries relation between user and team so constructing its unique id. + # so adding the date on the basis of it arrives for processing. time_created = datetime.utcnow().isoformat()[:-3]+'Z' - e_id = metadata["member"]["id"] + e_id = metadata["team"]["name"]+"/"+str(metadata["member"]["id"]) if event_type == "repository": time_created = metadata["repository"]["created_at"] e_id = metadata["repository"]["id"] + + if event_type == "team_add": + # Adding the date on the basis of it arrives for processing. + time_created = datetime.utcnow().isoformat()[:-3]+'Z' + # This event doesn't have unique id as it carries relation between repo and team so constructing its unique id. + # Its data would carry repository id and team id which would be used for analysis. + e_id = str(metadata["repository"]["id"])+"/"+metadata["team"]["name"] github_event = { "event_type": event_type,