leikind / wice_grid

A Rails grid plugin to create grids with sorting, pagination, and (automatically generated) filters
MIT License
537 stars 215 forks source link

bug filtering by dates #262

Open adrian-chang-alcover opened 8 years ago

adrian-chang-alcover commented 8 years ago

When I filter by min and max dates, the result set includes objects with a day after the date upper filter. For example, when I filter by dates from April 17 to April 19, objects with date April 20 are included.

leikind commented 8 years ago

the sql that the plugin generates would be awesome. https://github.com/leikind/wice_grid/issues/228

adrian-chang-alcover commented 8 years ago

I'm using Rails 4.2.3 and wice_grid version 3.5.0. There aren't errors in my JS console and neither in my web server.

These are the parameters of the request:

Parameters: {"grid"=>{"f"=>{"date"=>{"fr"=>{"year"=>"2015", "month"=>"10", "day"=>"17"}, "to"=>{"year"=>"2015", "month"=>"10", "day"=>"17"}}}}}

and this is the sql executed:

SELECT COUNT(*) FROM "kewelta_core_analytics" 
WHERE (( kewelta_core_analytics.date >= '2015-10-17'  
and  kewelta_core_analytics.date <= '2015-10-18' ))

I have seen in this file https://github.com/leikind/wice_grid/blob/rails3/lib/wice/columns/common_js_date_datetime_conditions_generator_mixin.rb that 1 day is added to the original opts[:to] parameters.

Thanks in advanced.

leikind commented 8 years ago

The code to which you are referring does not even exist in 3.5.0. If you run bundle open wice_grid you won't find that file.

Which date control are you using?

With the latest version 3.6.0.pre4 I cannot reproduce this behavior. Look: http://wicegrid.herokuapp.com/dates?grid%5Bf%5D%5Bdue_date%5D%5Bfr%5D=2016-10-12&grid%5Bf%5D%5Bdue_date%5D%5Bto%5D=2016-10-12 and one day before only shows one day before http://wicegrid.herokuapp.com/dates?grid%5Bf%5D%5Bdue_date%5D%5Bfr%5D=2016-10-11&grid%5Bf%5D%5Bdue_date%5D%5Bto%5D=2016-10-11

I think this has been fixed in 3.6.0.pre4. I would appreciate if you tested your app with 3.6.0.pre4. But if you do, do this in a separate branch. The API has changed : https://github.com/leikind/wice_grid/wiki/What's-New-In-3.6.0 the most important changes are assoc: and how you specify which datepicker to use.

adrian-chang-alcover commented 8 years ago

I was using: Wice::Defaults::DEFAULT_FILTER_FOR_DATE = :rails_date_helper and the problem persisted even when I update to version 3.6.0.pre4 I fixed it using: Wice::Defaults::DEFAULT_FILTER_FOR_DATE = :bootstrap_datepicker Now, it works perfectly

leikind commented 8 years ago

ok that's a bug report