Permalink
Browse files

Refactoring for date_range_scoped method in meta_date_extension. It w…

…orks for me, but it is necesary to review with Alejando Juarez
  • Loading branch information...
1 parent ca2da4a commit e55322edab60b17217636656aac70bd81c249617 @martinezo martinezo committed Dec 7, 2012
Showing with 11 additions and 8 deletions.
  1. +11 −8 lib/salva/meta_date_extension.rb
View
19 lib/salva/meta_date_extension.rb
@@ -73,14 +73,17 @@ def date_range_scopes
unless respond_to? :among
scope :among, lambda { |start_date, end_date|
where{
- ({:start_date.gteq => start_date, :end_date.lteq => end_date}) |
- ({:start_date.lt => start_date, :end_date.gt => end_date}) |
- ({:start_date.lteq => start_date, :end_date.lteq => end_date, :end_date.gteq => start_date}) |
- ({:start_date.gteq => start_date, :end_date.gteq => end_date, :start_date.lteq => end_date})
- ({:start_date.gteq => start_date, :end_date => nil, :start_date.lteq => end_date}) |
- ({:end_date.lteq => end_date, :start_date => nil, :end_date.gteq => start_date}) |
- ({:start_date.gteq => start_date, :end_date.lteq => end_date, :start_date.lt => end_date}) |
- ({:end_date.lteq => end_date, :end_date.gteq => start_date, :start_date.lt => end_date})
+ ({:start_date.gteq => start_date, :start_date.lteq => end_date }) |
+ ({:end_date.gteq => start_date, :end_date.lteq => end_date }) |
+ ({:start_date.lt => start_date, :end_date.gt => end_date } | {:end_date => nil})
+ #({:start_date.gteq => start_date, :end_date.lteq => end_date}) | da
+ #({:start_date.lt => start_date, :end_date.gt => end_date}) |
+ #({:start_date.lteq => start_date, :end_date.lteq => end_date, :end_date.gteq => start_date}) |
+ #({:start_date.gteq => start_date, :end_date.gteq => end_date, :start_date.lteq => end_date})
+ #({:start_date.gteq => start_date, :end_date => nil, :start_date.lteq => end_date}) |
+ #({:end_date.lteq => end_date, :start_date => nil, :end_date.gteq => start_date}) |
+ #({:start_date.gteq => start_date, :end_date.lteq => end_date, :start_date.lt => end_date}) |
+ #({:end_date.lteq => end_date, :end_date.gteq => start_date, :start_date.lt => end_date})
}
}

0 comments on commit e55322e

Please sign in to comment.