Identify IceCube recurring events by ID once they have occurred

254 Views Asked by At

I am attempting to use the ice_cube gem to set up a schedule for recurring shifts. What I am struggling with is the recurring events are not real instances of my model with an ID; I need to be able to reference each event to associate it with a shift_confirmation method (detailing things like the actual end time vs. the booked end time, whether the shift has been paid, etc.).

Where I'm struggling is that if I add an actual instance of my model, as opposed to a recurring instance, I will end up with both - the instance I can refer to with an ID, and also a recurring instance.

I have considered whether I can add an IceCube exception that removes a shift from the recurrence schedule each time a user wants to edit it (e.g. to mark it complete, paid, etc.), and create an instance of my model, but this seems very unclean - there must be a better way.

Is there any way to refer definitively to an specific event in an ice_cube recurring schedule, so that I can do things like mark it paid (which would be in an associated model)?

2

There are 2 best solutions below

0
A. Schippers On

When you create an schedule, the schedule has an idea, probably you can use this in your structure.

I viewed this post, because i've a similar problem.

I've an table activities, with start-, end datum and duration and an related table schedule with the reference 'activity_id'. I didn't want to store the ice-cube to_yaml string, because I want the option to add 'closing dates' in the future on a central place, without parsing every record again.

If you show your structure, maybe I can be of some help.

Regards, sander

0
Yshmarov On

Check out the schedulable gem, it lets you persist event_occurrences in the database and let's your "schedule" edit only future occurrences.