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:
		
							parent
							
								
									11f042e387
								
							
						
					
					
						commit
						a23dad737f
					
				@ -151,17 +151,18 @@ module GitHub
 | 
				
			|||||||
  def self.search_query_string(*main_params, **qualifiers)
 | 
					  def self.search_query_string(*main_params, **qualifiers)
 | 
				
			||||||
    params = main_params
 | 
					    params = main_params
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (args = qualifiers.fetch(:args, nil))
 | 
					    from = qualifiers.fetch(:from, nil)
 | 
				
			||||||
      params << if args.from && args.to
 | 
					    to = qualifiers.fetch(:to, nil)
 | 
				
			||||||
        "created:#{args.from}..#{args.to}"
 | 
					
 | 
				
			||||||
      elsif args.from
 | 
					    params << if from && to
 | 
				
			||||||
        "created:>=#{args.from}"
 | 
					      "created:#{from}..#{to}"
 | 
				
			||||||
      elsif args.to
 | 
					    elsif from
 | 
				
			||||||
        "created:<=#{args.to}"
 | 
					      "created:>=#{from}"
 | 
				
			||||||
      end
 | 
					    elsif to
 | 
				
			||||||
 | 
					      "created:<=#{to}"
 | 
				
			||||||
    end
 | 
					    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}" }
 | 
					      Array(value).map { |v| "#{key.to_s.tr("_", "-")}:#{v}" }
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user