Created
October 4, 2016 12:24
-
-
Save dmitry/76c5b429052022506c425a2861f4dce5 to your computer and use it in GitHub Desktop.
9flats
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var value = 1; | |
var c = days.length; | |
for (var i = 0; i < c; i++) { | |
var v = _source.minimum_stays[days[i]]; | |
if (v && value < v) { | |
value = v; | |
} | |
} | |
if (value == 1) { | |
value = _source.minimum_nights | |
} | |
c >= value; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# days.map do |date| | |
# { | |
# or: [ | |
# { | |
# and: [ | |
# { | |
# and: days.map do |d| | |
# { | |
# bool: { | |
# must: { | |
# not: { | |
# exists: { | |
# field: "minimum_stays.#{d}" | |
# } | |
# } | |
# } | |
# } | |
# } | |
# end | |
# }, | |
# { | |
# bool: { | |
# must: { | |
# range: { | |
# minimum_nights: { | |
# lte: days.size | |
# } | |
# } | |
# } | |
# } | |
# } | |
# ] | |
# }, | |
# { | |
# and: [ | |
# { | |
# bool: { | |
# must: { | |
# exists: { | |
# field: "minimum_stays.#{date}" | |
# } | |
# } | |
# } | |
# }, | |
# { | |
# bool: { | |
# must: { | |
# range: { | |
# "minimum_stays.#{date}" => { | |
# lte: days.size | |
# } | |
# } | |
# } | |
# } | |
# } | |
# ] | |
# }, | |
# { | |
# and: [ | |
# { | |
# or: days.map do |d| | |
# { | |
# bool: { | |
# must: { | |
# exists: { | |
# field: "minimum_stays.#{d}" | |
# } | |
# } | |
# } | |
# } | |
# end | |
# }, | |
# bool: { | |
# must: { | |
# not: { | |
# exists: { | |
# field: "minimum_stays.#{date}" | |
# } | |
# } | |
# } | |
# } | |
# ], | |
# }, | |
# ] | |
# } | |
# end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment