Skip to content

Commit a23dad7

Browse files
committed
Fix constructing search query strings with date ranges
- 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.
1 parent 11f042e commit a23dad7

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

Library/Homebrew/utils/github.rb

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,17 +151,18 @@ def self.private_repo?(full_name)
151151
def self.search_query_string(*main_params, **qualifiers)
152152
params = main_params
153153

154-
if (args = qualifiers.fetch(:args, nil))
155-
params << if args.from && args.to
156-
"created:#{args.from}..#{args.to}"
157-
elsif args.from
158-
"created:>=#{args.from}"
159-
elsif args.to
160-
"created:<=#{args.to}"
161-
end
154+
from = qualifiers.fetch(:from, nil)
155+
to = qualifiers.fetch(:to, nil)
156+
157+
params << if from && to
158+
"created:#{from}..#{to}"
159+
elsif from
160+
"created:>=#{from}"
161+
elsif to
162+
"created:<=#{to}"
162163
end
163164

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

0 commit comments

Comments
 (0)