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.
This commit is contained in:
Issy Long 2024-06-02 14:31:18 +01:00
parent 11f042e387
commit a23dad737f
No known key found for this signature in database

View File

@ -151,17 +151,18 @@ module GitHub
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