Skip to content

Commit

Permalink
Merge branch 'github2_add_reviews' of 'https://github.com/zhquan/Grim…
Browse files Browse the repository at this point in the history
…oireELK'

Merges #1024
Closes #1024
  • Loading branch information
zhquan committed Jan 21, 2022
2 parents 1b2ccbd + 1acffd8 commit b174a12
Show file tree
Hide file tree
Showing 4 changed files with 928 additions and 9 deletions.
13 changes: 13 additions & 0 deletions grimoire_elk/enriched/github2.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,20 +342,32 @@ def enrich_pulls(self, item, eitem):
eitems = []

comments = item['data'].get('review_comments_data', [])
reviews = item['data'].get('reviews_data', [])
if comments:
rich_item_comments = self.get_rich_pull_reviews(comments, eitem)
eitems.extend(rich_item_comments)
if reviews:
rich_item_reviews = self.get_rich_pull_reviews(reviews, eitem)
eitems.extend(rich_item_reviews)

return eitems

def get_rich_pull_reviews(self, comments, eitem):
ecomments = []

for comment in comments:
# If the comment comes from a review is "Approve" or "Change requests"
# there is a "submitted_at" instead of "updated_at"
if 'updated_at' not in comment:
comment['updated_at'] = comment['submitted_at']

ecomment = {}

self.copy_raw_fields(self.RAW_FIELDS_COPY, eitem, ecomment)

# Review state
ecomment['review_state'] = comment.get('state', '')

# Copy data from the enriched pull
ecomment['pull_labels'] = eitem['pull_labels']
ecomment['pull_id'] = eitem['pull_id']
Expand Down Expand Up @@ -385,6 +397,7 @@ def get_rich_pull_reviews(self, comments, eitem):
ecomment.update(self.__get_reactions(comment))

ecomment['comment_updated_at'] = comment['updated_at']
ecomment['comment_created_at'] = comment.get('created_at', comment['updated_at'])

# Add id info to allow to coexistence of items of different types in the same index
ecomment['id'] = '{}_review_comment_{}'.format(eitem['id'], comment['id'])
Expand Down
2 changes: 2 additions & 0 deletions schema/github2_pull_requests.csv
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ author_uuid,keyword,true,"Pull request author UUID from SortingHat profile."
body,keyword,true,"Body of the pull request/comment."
body_analyzed,text,false,"Body of the pull request/comment."
code_merge_duration,float,true,"Difference in days between creation and merging dates."
comment_created_at,date,true,"Date when the comment was created."
comment_updated_at,date,true,"Date when the comment was updated."
demography_max_date,date,true,"Date of the latest pull request of the corresponding author. Available only when demography study is active."
demography_min_date,date,true,"Date of the first (oldest) pull request of the corresponding author. Available only when demography study is active."
Expand Down Expand Up @@ -68,6 +69,7 @@ reaction_thumb_up,long,true,"Number of reactions '+1'."
reaction_total_count,long,true,"Number of total reactions."
repository,keyword,true,"Repository name."
repository_labels,keyword,true,"Custom repository labels defined by the user."
review_state,keyword,true,"Review type APPROVED, COMMENTED, CHANGES_REQUESTED, or empty."
sub_type,keyword,true,"Type of the comment (pull review comment)."
tag,keyword,true,"Perceval tag."
time_open_days,float,true,"Time the pull request is open counted in days."
Expand Down
Loading

0 comments on commit b174a12

Please sign in to comment.