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

[github2] Add comments from "Approval" and "Change requests" #1024

Merged
merged 1 commit into from
Jan 21, 2022
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
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