Skip to content

Commit

Permalink
fixes bug detecting date filters
Browse files Browse the repository at this point in the history
previously was accidentally picking up fields like "on_this_day_k"
because the "_d" include wasn't particular about the end of string
but this regex should match more appropriately to *_d fields only
  • Loading branch information
jduss4 committed Oct 17, 2017
1 parent 94df989 commit c170475
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/services/search_item_req.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def facets
# histograms use a different ordering terminology than normal aggs
f_type = type == "_term" ? "_key" : "_count"

if f.include?("date") || f.include?("_d")
if f.include?("date") || f[/_d$/]
# NOTE: if nested fields will ever have dates we will
# need to refactor this to be available to both
if f.include?(".")
Expand Down Expand Up @@ -158,7 +158,7 @@ def filters
}
filter_list << nested
# DATE FIELD FILTER
elsif filter[0].include?("date") || filter[0].include?("_d")
elsif filter[0].include?("date") || filter[0][/_d$/]
# TODO rethink how all of the below is functioning, it is terrible

# NOTE: if nested fields contain date this will have to be changed
Expand Down

0 comments on commit c170475

Please sign in to comment.