Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Between Queries for Timestamps #37

Open
stevievines opened this issue Jun 6, 2015 · 2 comments
Open

Between Queries for Timestamps #37

stevievines opened this issue Jun 6, 2015 · 2 comments

Comments

@stevievines
Copy link

I was wondering whether it is possible to do "between" queries with the Ohm::Timestamps module.

For example, is it possible to do a query like this ActiveRecord query:

 User.where(created_at: @date_start..@date_end)

Right now, I am just grabbing them all, sorting by created_at and iterating over the results using a select:

AnonymousVisitor.find(store_id: store_id).sort_by(:created_at).select do |visitor|
  visitor.created_at >= date_start && visitor.created_at < date_end
end

But I imagine this will be an expensive operation. Is there a good way to do this?

@TangMonk
Copy link

+1

@soveran
Copy link
Collaborator

soveran commented Mar 18, 2017

@stevievines @TangMonk I think there may be a way to provide that functionality. I did some work in Ohm for implementing rankings, and I think it could be combined with timestamps to get what you need. The new code is in the rank branch in Ohm, and if you want to test it I can prepare some examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants