🚩

How does the Calendar importer detect Places and Addresses?

Events always have a Partner (who organises it) and can optionally have a Place (where it is) and/or Address. This is why the database structure works how it does now.

This document is therefore about how to deduce Place, or not.

Events should show up in three places:

  1. The Partner page (/partner1/x)
  2. The Place of the event, if it has one (/partner2/x)
  3. Site event listings (/events): any neighbourhood event listing that contains the partner, place, or address of the event

Scenario 1: An organiser sets up a calendar for a new neighbourhood

The first step in starting a new PlaceCal instance is often based on an existing neighbourhood calendar someone has set up by sharing a Google calendar, or with an area Facebook group or the like. In the first instance we want to just import this calendar to give immediate value.

This big source calendar might have events on by say, 6-12 partners, with a mix of regular and one-off events. The location field in the calendar is how we tell them apart, but it’s fair to assume addresses will be input inconsistently.

The idea is that as time goes on, they onboard the partners on the calendar directly and delete them from their source calendar.

This is what the event strategy is designed for.

We could potentially add a field to the Calendar model to indicate if the person listing the events is the organiser or just some helpful community development officer who happens to be uploading them.

S1.1: Event strategy, source event location is empty

In the first instance when we had only one area this was a non-issue - it just imported everything anyway.

At some point we made the ‘organiser’ field mandatory, which fixed a lot of these issues but it still makes this case tricky for this scenario. Maybe we need an option to have “organiser” be more like “event listed by” so that they show up on the person doing the listing’s partner page but it’s clear they’re not by that partner.

Response: Place: nil, Address: nil, flag warning for each event

S1.2: Event strategy, source event location has an address that does not match a known place

It should look at the address field on every source event, see if it matches a known Partner in PlaceCal, and if so normalise the address and connect the two.

If there’s no match it should reject importing and make a message (”Could not import: #{address} matches no known venue. Create it?”)

Response: Place: nil, Address: copy over and normalise if possible

S1.3: Event strategy, source event location matches a known place

If the address is known then great, we have a hit. Normalise the address, link the place.

Response: Place: based on address, Address: Place.address

Scenario 2: A partner sets up a calendar for events in one place

S2.1: Use location strategy

This is very simple — the Organiser and Place is set in the PlaceCal interface.

Scenario 3: A partner sets up a calendar of events at a range of places

S3.1: Use default location strategy

Provide a fallback to a default Place if the address can’t be matched to another Place

S3.2: Use event strategy

Don’t set Place for anything we can’t find an address for and raise an import error.

Importing logic

Location comes from the imported event

Place comes from the default location setting in PlaceCal unless overridden by the importer, as shown.

This process sets 2 properties of Events:

  1. Place, which is a Partner that something happens to be at. The intended use case for this is community venues, or big institutions that don’t maintain their own listing but might still be added to PlaceCal by an organiser. It also covers where there is one Partner who manages two (or more) venues and for whatever reason wants to do this all on one calendar — maybe input source is a website feed.
  2. Address, which is a standard street address model. This could be anywhere. This can be based on the event location field in the source data, or the address of the partner or place it’s attached to.
event source location
calendar place
Event strategy
Event override strategy
Default location strategy (place)
Room Number strategy
no
no
warning1
warning1
n/a ?
n/a ?
yes
no
event.Place = attempt to match location event.Address = Place.address || location info1
event.Place = attempt to match location event.Address = calendar.Place.address || location info1
n/a ?
n/a ?
no
yes
warning2
event.Place = calendar.Place event.Address = calendar.Place.address
event.Place = calendar.Place event.Address = calendar.Place.address
event.Place = calendar.Place event.Address = calendar. Place.address
yes
yes
event.Place = attempt to match location event.Address = calendar.Place.address || location info1
event.Place = attempt to match location OR default place event.Address = calendar.Place.address || location
event.Place = calendar.Place event.Address = calendar.Place.address
event.Place = calendar.Place event.Address = “#{location}, Place.address”

Table notes:

warning1: Could not determine where this event is. Add an address to the location field of the source calendar, or choose another import strategy with a default location.

warning2: Could not determine where this event is. A default location is set but the importer is set to ignore this. Add an address to the location field of the source calendar, or choose another import strategy with a default location.

info1: If match location is unsuccessful, raise a message “This location was not recognised by PlaceCal, would you like to add it?”