DEV Community

Tubby
Tubby

Posted on

Optimal way to store/consume scheduled/recurring events

I am working on best way to store the scheduled and recurring events. I am taking inspiration from here - https://github.com/bmoeskau/Extensible/blob/master/recurrence-overview.md.

I will be storing any events as RRule(iCal Events - https://tools.ietf.org/html/rfc5545) and duration of the event as separate properties.
The structure will look like this.

class Schedule {
    String rRule; //Varchar
    String startTime; //DateTime
    String endTime; //DateTime
} 

With this structure the clients can show the events on calendar without querying the API.

It gets interesting when the events can be modified.
For Ex: Schedule = 'Daily at 10:00, duration 2 Hours' creates an event for everyday. But the user can modify(disable) any particular event. and this change should be stored. For this the above article suggests to use EventException(https://github.com/bmoeskau/Extensible/blob/master/recurrence-overview.md#eventexception) where the modified events are stored.

But in my use case I want to store if the event was successfully completed. (I can mitigate this by saying any event by default is successful, if there was some modification I store it in EventException and need to be fetched from here)


So I would like your opinion if this is the best way to do it? Did you have similar experience and how it was solved.
I am working on it to design a solution which reduces the work for both frontend and backend.

Also is it wise to store the RRule as a separate entity instead of a string?

Top comments (0)