Effectively retrieve ice_cube charts for a given time period

I am studying using Ice Cube https://github.com/seejohnrun/ice_cube for recurring events. My question is that if I then need to receive any events that fall within a given period of time (for example, a day or during a week), is there a better way than passing everything through them, like this:

items = Records.find(:all) items.each do |item| schedule = item.schedule if schedule.occurs_on?(Date.new) #if today is a recurrence, add to array end end 

It seems terribly inefficient, but I'm not sure how to do it.

+6
source share
1 answer

This approach - but what people do more often leads to the denormalization of their schedules in a format that is convenient to request.

You may have a collection called something like ScheduleOccurrences, which you create every week / and then request it.

Unfortunately, it should work this way, but adhering to the iCal schedule management method has led IceCube to need to format its data in certain ways (in particular, methods that may comply with iCal RFC requirements).

I recently thought about what the library would look like, which has removed some of these restrictions, for more flexibility like this, but its definitely still not working a bit.

Hope this helps

+4
source

Source: https://habr.com/ru/post/917057/