Add Montreal data and page - #57
Conversation
| RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - | ||
|
|
||
| RUN apt-get update && apt-get install -y --no-install-recommends nodejs gdal-bin | ||
| RUN apt-get update && apt-get install -y --no-install-recommends nodejs gdal-bin npm |
There was a problem hiding this comment.
I got this error from docker compose build before explicitly installing npm here:
> [app 9/11] RUN npm install:
0.192 /bin/sh: 1: npm: not found
------
failed to solve: process "/bin/sh -c npm install" did not complete successfully: exit code: 127
| // Create the autocomplete object | ||
| let autocomplete = new google.maps.places.Autocomplete( | ||
| inputElement, { componentRestrictions: { country: "us" } } | ||
| inputElement, { componentRestrictions: { country: ["us", "ca"], } } |
There was a problem hiding this comment.
This means the autocomplete options will include both US and Canada results for both the Chicago and Montreal pages. I think this is fine because they're sorted by proximity to the user anyway, but if we wanted to we could only show US results on the Chicago page and Montreal results on the Canada page.
| </div> | ||
| <div class="form-group"> | ||
| <div> | ||
| <input type="checkbox" id="enable-v2" name="enable-v2" checked /> |
There was a problem hiding this comment.
This new file is mostly copied from index.html, other than turning on enable-v2 by default here and passing the city name to new App(). This could probably be DRYer but if we publish this let's talk through how the two pages would depart, if we actually want them at two different routes, etc.
| try: | ||
| city = request.GET['city'] | ||
| except KeyError: | ||
| city = 'chicago' |
There was a problem hiding this comment.
Chicago is hardcoded here as the city default if it's somehow not provided
| ELSE way.reverse_cost | ||
| END AS reverse_cost | ||
| FROM chicago_ways AS way | ||
| FROM {city}_ways AS way |
There was a problem hiding this comment.
This was such a small adjustment needed to the SQL 🎉

As a means of getting reacquainted with this app, I've gone ahead and added a page for Montreal. Wow what a nice project to add to! This worked very smoothly so far.
To test:
docker compose run --rm -w /app postgres make db/import/montreal.tabledocker-compose upI'll leave some more notes below. This is my first time looking at a Django app in like 3 years so definitely open to code organization/style changes.