Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tags schema with full replication #160

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions tap_github/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
'pull_requests':['id'],
'stargazers': ['user_id'],
'releases': ['id'],
'tags': ['node_id'],
'reviews': ['id'],
'review_comments': ['id'],
'pr_commits': ['id'],
Expand Down Expand Up @@ -781,6 +782,28 @@ def get_all_releases(schemas, repo_path, state, mdata, _start_date):

return state

def get_all_tags(schemas, repo_path, state, mdata, _start_date):
# The volume of tags can safely be considered low

with metrics.record_counter('tags') as counter:
for response in authed_get_all_pages(
'tags',
'https://api.github.com/repos/{}/tags?sort=node_id&direction=desc'.format(repo_path)
):
tags = response.json()
extraction_time = singer.utils.now()
for t in tags:
t['_sdc_repository'] = repo_path

# transform and write release record
with singer.Transformer() as transformer:
rec = transformer.transform(t, schemas, metadata=metadata.to_map(mdata))
singer.write_record('tags', rec, time_extracted=extraction_time)
singer.write_bookmark(state, repo_path, 'tags', {'since': singer.utils.strftime(extraction_time)})
counter.increment()

return state

def get_all_pull_requests(schemas, repo_path, state, mdata, start_date):
'''
https://developer.github.com/v3/pulls/#list-pull-requests
Expand Down Expand Up @@ -1099,6 +1122,7 @@ def get_request_timeout():
'collaborators': get_all_collaborators,
'pull_requests': get_all_pull_requests,
'releases': get_all_releases,
'tags': get_all_tags,
'stargazers': get_all_stargazers,
'events': get_all_events,
'issue_events': get_all_issue_events,
Expand Down
33 changes: 33 additions & 0 deletions tap_github/schemas/tags.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"type": ["null", "object"],
"additionalProperties": false,
"properties": {
"name": {
"type": ["null", "string"]
},
"zipball_url": {
"type": ["null", "string"]
},
"tarball_url": {
"type": ["null", "string"]
},
"commit": {
"type": ["null", "object"],
"additionalProperties": false,
"properties": {
"sha": {
"type": ["null", "string"]
},
"url": {
"type": ["null", "string"]
}
}
},
"node_id": {
"type": ["null", "string"]
},
"_sdc_repository": {
"type": ["string"]
}
}
}