javascript - How to search by duration in Algolia -


let's building hotel booking platform, , every room record has availability calendar. common search criteria search duration. user inputs start date , end date, , database fetches rooms not occupied duration.

i have implemented naive approach store occupied days array of days.

attribute :occupied_at_i     array = []     if !occupied_at.empty?         occupied_at.each |date|             array << time.parse(date).to_i         end     end     array end 

and @ client side, add following javascript code cross-check if day in numericrefinement

// date filters $('.date-field')     .on('change', function() {         if(_.every(_.map($('.date-field'), function(date) {return _.isempty(date.value) }), function(n) {return n==false;})) {             helper.clearrefinements('occupied_at_i');             var arrayofdates = adddatefilters();             _.foreach(arrayofdates, function(n) {                 helper.addnumericrefinement('occupied_at_i', '!=', n);             });             showclearallfilters();             helper.search();         }     }); 

so, not way it, wondering what's better leverage on algolia , search duration?

thanks


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -