Code Monkey home page Code Monkey logo

active_record_date_range_scopes's People

Contributors

tylerrick avatar

Watchers

 avatar  avatar  avatar

Forkers

dburry

active_record_date_range_scopes's Issues

use arel between, instead of chaining after and before together

In the accompanying pull request #1 , I'm changing the *_between scope to use arel's between operator, instead of chaining arel's letq and gteq together by chaining the *_after and *_before scopes together...

This does 2 things:

  1. It may in certain circumstances make it more time and resource efficient, when the database has an optimized between type operator. For example, it might take greater advantage of indexes, or other resource enhancements, by making it one operation instead of two.
  2. It gets rid of this deprecation warning in Rails 6.1.8 (and the breakage in Rails 7):
DEPRECATION WARNING: Merging ("enrollments"."cached_latest_followup_date" >= '2018-01-01 07:00:00') and
("enrollments"."cached_latest_followup_date" <= '2018-01-03 06:59:59.999999') no longer maintain both conditions,
and will be replaced by the latter in Rails 7.0. To migrate to Rails 7.0's behavior, use
`relation.merge(other, rewhere: true)`. (called from block in delegate_date_range_scopes at
/Users/dburry/vop/active_record_date_range_scopes/lib/active_record/date_range_scopes.rb:170)

For more information on this change in Rails 7, see: https://www.mintbit.com/blog/rails-7-dot-0-and-merging-activerecord-conditions

Allow a Range to be passed in instead of before, after

This would allow:

Book.created_between(3.years.ago, 1.year.ago)
Book.created_between('2020-01-01', '2020-01-31')

to optionally be written as this instead:

Book.created_between(3.years.ago .. 1.year.ago)
Book.created_between('2020-01-01' .. '2020-01-31')

Builds on the work of #2.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.