I'm developing a calendar import system for my app and aim to import all occurrences of an event. I'm avoiding checking the start_time and end_time to prevent creating events when only the dates have changed in their calendar.
To prevent duplication, I've been using the event.uid, but it only exists on the event itself and not on individual occurrences, making it ineffective.
Do you have any suggestions on how to import occurrences without duplication?
Here is an extract of my code:
events.each_with_index do |event, index|
event.occurrences_between(min_date, Time.current.end_of_day).each do |occurrence|
TimeEntry
.where(
ical_uid: event.uid.to_s,
user: calendar_sync.user,
team: calendar_sync.team,
calendar_sync: calendar_sync,
)
.first_or_create(
description: event.summary.presence,
start_at: occurrence.start_time,
end_at: occurrence.end_time
)
end
end
I'm developing a calendar import system for my app and aim to import all occurrences of an event. I'm avoiding checking the
start_time
andend_time
to prevent creating events when only the dates have changed in their calendar.To prevent duplication, I've been using the
event.uid
, but it only exists on the event itself and not on individual occurrences, making it ineffective.Do you have any suggestions on how to import occurrences without duplication?
Here is an extract of my code: