Recurring events, how to store them?

风流意气都作罢 提交于 2019-12-24 15:54:33

问题


I found a few questions asked before regarding recurring events but I have not gone into one that get's close to my need. I am struggling to understand how to deal with recurring events for a notification system.

I know of two options so far:

  1. Store a single event that has a pattern in it and calculate on the fly any future event (for something like repeat forever, etc). Use cron patterns or even better RRULE stuff.

  2. Store all future events as single events until a certain date.

My problem with Option 1 is that I need my events to hold some other data like confirmations and if I have a repeating event I might need to hold multiple confirmations for each recurring event. This transforms into a nasty hack to make things work and I don't even want to think how to deal with displaying past and future events that have other data associated with them.

Option 2 is better since I can store all the extra data associated with each even in the single event. The problem comes with dealing with future events. First, if the event repeats forever than how much should I go for storing events. Do I just do chunks and generate on the fly if the user wants to display future event that was not already generated? This option also feels like a hack.

So far I have read a bit about RRULE and found that I can use rrule.js for frontend and a few other packages for backend.

Edit 1: to better clarify, i am not completely set to use full iCal format standards and am thinking to only make use of RRules. But, I might change my mind since I am still looking for options.

How are iCal Vevents and rrules supposed to be stored in the DB?


回答1:


It is not clear whether you care about rrule only as a convenient way to express something that recurs or whether you want to use the full iCalendar format.

Assuming the later, Option 1 is covered by RFC5545: you would store a "master" VEVENT, containing the base information, along with the RRULE, + one VEVENT for each instance that is an "exception" to the base event, where each exception is identified by its RECURRENCE-ID.

RFC5545 does not have any example of such event but RFC5546 has something pretty close at https://tools.ietf.org/html/rfc5546#section-4.4.8 (using RDATE instead of RRULE and no need for the METHOD property but you get the idea).



来源:https://stackoverflow.com/questions/35284212/recurring-events-how-to-store-them

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!