Skip to content

Commit

Permalink
Merge pull request #14821 from issyl0/support-date-ranges-in-pr-revie…
Browse files Browse the repository at this point in the history
…ws-query

dev-cmd/contributions: Support date ranges in PR reviews query
  • Loading branch information
MikeMcQuaid committed Feb 28, 2023
2 parents 86aeac6 + a2d31fa commit 6db7732
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Library/Homebrew/dev-cmd/contributions.rb
Expand Up @@ -175,7 +175,7 @@ def scan_repositories(repos, person, args)
commits: GitHub.repo_commit_count_for_user(repo_full_name, person, args),
coauthorships: git_log_trailers_cmd(T.must(repo_path), person, "Co-authored-by", args),
signoffs: git_log_trailers_cmd(T.must(repo_path), person, "Signed-off-by", args),
reviews: GitHub.count_issues("", is: "pr", repo: repo_full_name, reviewed_by: person),
reviews: GitHub.count_issues("", is: "pr", repo: repo_full_name, reviewed_by: person, args: args),
}
end

Expand Down
14 changes: 12 additions & 2 deletions Library/Homebrew/utils/github.rb
Expand Up @@ -159,11 +159,21 @@ def private_repo?(full_name)
def search_query_string(*main_params, **qualifiers)
params = main_params

params += qualifiers.flat_map do |key, value|
if (args = qualifiers.fetch(:args, nil))
params << if args.from && args.to
"created:#{args.from}..#{args.to}"
elsif args.from
"created:>=#{args.from}"
elsif args.to
"created:<=#{args.to}"
end
end

params += qualifiers.except(:args).flat_map do |key, value|
Array(value).map { |v| "#{key.to_s.tr("_", "-")}:#{v}" }
end

"q=#{URI.encode_www_form_component(params.join(" "))}&per_page=100"
"q=#{URI.encode_www_form_component(params.compact.join(" "))}&per_page=100"
end

def url_to(*subroutes)
Expand Down

0 comments on commit 6db7732

Please sign in to comment.