Skip to content

Commit

Permalink
Fix constructing search query strings with date ranges
Browse files Browse the repository at this point in the history
- Both `from` and `to` are now separate keyword arguments
  in a bunch of places, not part of `args`.
- When we switched this around, we didn't realize this
  method needed updating to correctly construct the time
  range query.
- This led to further inaccurate counts in `brew contributions`
  for reviews, since `from` and `to` are not valid search qualifiers
  for the GitHub PR search APIs.
  • Loading branch information
issyl0 committed Jun 2, 2024
1 parent 11f042e commit a23dad7
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions Library/Homebrew/utils/github.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,18 @@ def self.private_repo?(full_name)
def self.search_query_string(*main_params, **qualifiers)
params = main_params

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
from = qualifiers.fetch(:from, nil)
to = qualifiers.fetch(:to, nil)

params << if from && to
"created:#{from}..#{to}"
elsif from
"created:>=#{from}"
elsif to
"created:<=#{to}"
end

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

Expand Down

0 comments on commit a23dad7

Please sign in to comment.