michael-maltsev / cheese-fork

A scheduling helper web application for Technion students
https://cheesefork.cf
GNU General Public License v3.0
50 stars 13 forks source link

Bug when importing several semester to the same calendar #19

Closed brkgr closed 3 years ago

brkgr commented 3 years ago

When importing to Google Calendar courses from cheesefork that was exported as an ical file, it writes a message: Screenshot 2020-10-19 123108 But it is far from just not importing some of the events. It makes a mess in the existing events in the calendar, it moved to trash some of them, made others disappear (with no possible restoration) and some of the new added events (from the exported ical) got the names and details of some old events from the calendar. The old ones are events from the previous semester, that were imported also from cheesefork.

A digging into the ical made me pretty sure that the reason is the UID that is given to the exported events - its format is UID:%d@cheesefork.cf where %d starts from 0 and increments by 1 for every event. The problem is that cheesefork generates the same UIDs for different semesters, resulting in the described mess.

I guess that the straightforward fix is to add a prefix or a suffix to the UID that will make it unique for each semester. Beyond that, maybe the UID should contain some unique course ID, so it will be consistent in case someone import it more than once.

michael-maltsev commented 3 years ago

I changed the code so that the current time is appended to the UID every time an iCalendar file is generated, making the UID unique. It's not ideal, since downloading and importing the same schedule multiple times will leave duplicates, but at least this behavior will now be consistent and predictable. It's tricky to generate a semantically proper UID for all events. For some events it can be just something like 2020-winter-234124-lecture-10@cheesefork.cf, but:

  1. Some lectures are split into more than one event, like this, making such UIDs non-unique (and each UID has to be unique).
  2. Custom events don't have this kind of information. "Sadnaot" events have only part of it.

For a Google Calendar user, I think it's best to use one of the two approaches:

  1. Use the URL provided by CheeseFork. See discussion and announcement.
  2. Create a new calendar every time an ics file is imported, and import the file into the newly created calendar. Too bad the way to do that is so clumsy UX-wise.