Skip to content

Commit

Permalink
Simplify into a bigger case statement
Browse files Browse the repository at this point in the history
  • Loading branch information
Maciej Szlosarczyk committed Dec 20, 2016
1 parent ac071c4 commit b73c3de
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions lib/terjira/client/jql_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,16 @@ def build_jql(options = {})
end.slice(*JQL_KEYS)

query = q_options.map do |key, value|
if value.is_a? Array
case
when value.is_a?(Array)
values = value.map { |v| "\"#{v.key_value}\"" }.join(',')
"#{key} IN (#{values})"
when value.key_value.to_s =~ /^\d+$/
"#{key}=#{value.key_value}"
when key.eql?('summary')
"#{key}~\"#{value.key_value}\""
else
case
when value.key_value.to_s =~ /^\d+$/
"#{key}=#{value.key_value}"
when key.eql?('summary')
"#{key}~\"#{value.key_value}\""
else
"#{key}=\"#{value.key_value}\""
end
"#{key}=\"#{value.key_value}\""
end
end.reject(&:blank?).join(' AND ')

Expand Down

0 comments on commit b73c3de

Please sign in to comment.