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

[enriched] Add support for github pull request data #399

Merged
merged 2 commits into from
Jul 10, 2018
Merged
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
91 changes: 53 additions & 38 deletions grimoire_elk/enriched/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,59 @@ def get_time_to_first_attention(self, item):

@metadata
def get_rich_item(self, item):

rich_item = {}
if item['category'] == 'issue':
rich_item = self.__get_rich_issue(item)
elif item['category'] == 'pull_request':
rich_item = self.__get_rich_pull(item)
else:
logger.error("rich item not defined for GitHub category %s", item['category'])

return rich_item

def enrich_items(self, items):
total = super(GitHubEnrich, self).enrich_items(items)

logger.debug("Updating GitHub users geolocations in Elastic")
self.geo_locations_to_es() # Update geolocations in Elastic

return total

def enrich_onion(self, ocean_backend, enrich_backend,
no_incremental=False,
in_index_iss='github_issues_onion-src',
in_index_prs='github_prs_onion-src',
out_index_iss='github_issues_onion-enriched',
out_index_prs='github_prs_onion-enriched',
data_source_iss='github-issues',
data_source_prs='github-prs',
contribs_field='uuid',
timeframe_field='grimoire_creation_date',
sort_on_field='metadata__timestamp'):

super().enrich_onion(enrich_backend=enrich_backend,
in_index=in_index_iss,
out_index=out_index_iss,
data_source=data_source_iss,
contribs_field=contribs_field,
timeframe_field=timeframe_field,
sort_on_field=sort_on_field,
no_incremental=no_incremental)

super().enrich_onion(enrich_backend=enrich_backend,
in_index=in_index_prs,
out_index=out_index_prs,
data_source=data_source_prs,
contribs_field=contribs_field,
timeframe_field=timeframe_field,
sort_on_field=sort_on_field,
no_incremental=no_incremental)

def __get_rich_pull(self, item):
return {}

def __get_rich_issue(self, item):
rich_issue = {}

for f in self.RAW_FIELDS_COPY:
Expand Down Expand Up @@ -371,44 +424,6 @@ def get_rich_item(self, item):

return rich_issue

def enrich_items(self, items):
total = super(GitHubEnrich, self).enrich_items(items)

logger.debug("Updating GitHub users geolocations in Elastic")
self.geo_locations_to_es() # Update geolocations in Elastic

return total

def enrich_onion(self, ocean_backend, enrich_backend,
no_incremental=False,
in_index_iss='github_issues_onion-src',
in_index_prs='github_prs_onion-src',
out_index_iss='github_issues_onion-enriched',
out_index_prs='github_prs_onion-enriched',
data_source_iss='github-issues',
data_source_prs='github-prs',
contribs_field='uuid',
timeframe_field='grimoire_creation_date',
sort_on_field='metadata__timestamp'):

super().enrich_onion(enrich_backend=enrich_backend,
in_index=in_index_iss,
out_index=out_index_iss,
data_source=data_source_iss,
contribs_field=contribs_field,
timeframe_field=timeframe_field,
sort_on_field=sort_on_field,
no_incremental=no_incremental)

super().enrich_onion(enrich_backend=enrich_backend,
in_index=in_index_prs,
out_index=out_index_prs,
data_source=data_source_prs,
contribs_field=contribs_field,
timeframe_field=timeframe_field,
sort_on_field=sort_on_field,
no_incremental=no_incremental)


class GitHubUser(object):
""" Helper class to manage data from a Github user """
Expand Down
13 changes: 13 additions & 0 deletions grimoire_elk/raw/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,19 @@ def get_elastic_mappings(es_major):
}
}
},
"review_comments_data": {
"dynamic":false,
"properties": {
"body": {
"type": "text",
"index": true
},
"diff_hunk": {
"type": "text",
"index": true
}
}
},
"body": {
"type": "text",
"index": true
Expand Down