Best way to develop/manage/design recurring tasks/calendar

后端 未结 4 1347
执笔经年
执笔经年 2021-02-03 14:27

An example of what I\'m talking about is similar to Google Calendar. When a new recurring task is created.

After creating the recurring task \"template\" - which all of

4条回答
  •  醉话见心
    2021-02-03 15:09

    Store it all in the database.

    You want to have a "Task Template" table and a "Task" table where there is a one->many relationship.

    When the user indicates they want a task to reoccur, create a "Task Template" record and then create as many "Tasks" as the user has indicated (don't allow a user to create tasks too far into the future). Each Task is linked to the Task Template via a Foreign Key. The idea is that SQL is going to be more efficient at managing these records than trying to do this all in code based on one template. This way, you will have more option when your sorting and filtering your data. After all, writing a SQL query is easier than writing, testing, and maintaining a PHP function that manipulates the data.

    Some other tips I would give you is:

    • Try to get a lot of information in your "Task Template" record. Keep the number of tasks the Template covers, the date the last task ends, the time elapsed between the first task and the last, etc.. This "Meta Data" can help save you query time when you're looking to sort and filter tasks.
    • Put an index on the Date and FK field, this will help query time as well.
    • I just built two calendar apps at work that were pretty well received by the bosses. I used the "FullCalendar" JQuery plugin (http://arshaw.com/fullcalendar/). I used JQuery AJAX to handle most of my events, and it had built in support for Month, Day, and Week view.

提交回复
热议问题