How the importer works (wip)

(This is from the “import_events” function, onwards. It’s in like a psuedocode and probably can eventually be transformed into being a flowchart, maybe)


  • Grab a list of events into parsed_events
  • EXIT if parsed_events doesn’t contain any events
  • FOR each event:
    • Grab a list of occurrences we have seen within the given time period (A list of datetime objects - (? needs verification imo))
    • SKIP if the event data is set as private, or there are no occurrences in the list
    • Add the event data UID to a local list of event UIDs
    • Set the Partner of the event data to the Calendar’s Partner
    • IF the event’s location is either “set to a single preset location defined by the calendar” or “set to a single preset location, with the address field holding a room number”
      • Set the place_id of the event data to the Calendar’s place_id field
    • Otherwise, do (some complicated logic) to give us either a Partner or an Address for the location, and add the relation to the event data
    • Update notices with the error notice (if any) returned from either creating or updating an Event record for the event data we’ve constructed
  • Delete any events that start from today onwards if they are not in the list of event uids
  • Reload and update the Calendar's list of notices, last event checksum value, last import Datetime, and unset critical_error (Critical Error seems to be “there is an error in the importer”)

create or update events

  • Takes an event data
  • Grab all current and future instances of the event matching the event data GID, and if it is a recurring event,
  • Delete all the upcoming events whose start and end times are not in any of the newly scraped events