Skip to content

Commit

Permalink
Exclude website authors that skews numbers.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock committed Oct 9, 2023
1 parent d493d96 commit abd1504
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bin/commands/pr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Commands

if !options['ignore-unknown'] && prs.contributors[:unknown]&.any?
puts 'Add the following users to either data/users/members.txt, external.txt, students.txt or contractors.txt and re-run.'
prs.contributors[:unknown].keys.take(10).each do |user|
prs.contributors[:unknown].keys.each do |user|
puts user
system "open https://github.com/#{user}"
end
Expand Down
12 changes: 11 additions & 1 deletion lib/github/pull_requests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def page(options)
raise 'There are 1000+ PRs returned from a single query, reduce --page.' if data.size >= 1000

data.reject do |pr|
pr.user.type == 'Bot' || GitHub::Data.backports.any? { |b| pr.title&.downcase&.include?(b) }
pr.user.type == 'Bot' || GitHub::Data.backports.any? { |b| pr.title&.downcase&.include?(b) } || project_website_authors?(pr)
end
end

Expand All @@ -44,5 +44,15 @@ def query(options = {})
].compact
).compact.join(' ')
end

# exclude a high number of misleading contributions from a student program
# modifying https://github.com/opensearch-project/project-website/commits/main/_authors
def project_website_authors?(pr)
return false unless pr.repository_url == 'https://api.github.com/repos/opensearch-project/project-website'

repo = pr.repository_url.split('/')[4, 2].join('/')
files = $github.pull_request_files(repo, pr.number)
files.all? { |file| file.filename.start_with?('_authors/') }
end
end
end

0 comments on commit abd1504

Please sign in to comment.