Hi Josi,
So do people want these methods? How frequently do you use time ranges?
I’d find the surrounding
-methods useful for debugging in the console.
I’ll occasionally use a range to find incoming webhook events that arrived around the same time a buggy user was created. When I’m typing it, it does feel like it could be improved:
buggy user
u = User.find(123)
Find webhook events that happened around the same time
the buggy user was created.
events = WebhookEvent.where(created_at: (u.created_at - 2.minutes)…(u.created_at + 2.minutes))
``
My first reaction is I do prefer it with using and_the_surrounding
:
Same query using proposed method:
events = WebhookEvent.where(created_at: u.created_at.and_the_surrounding(2.minutes))
``
Eliot