Home

Awesome

PlanningAlerts

example workflow Test Coverage Maintainability View performance data on Skylight

Find out and have your say about development applications in your area.

This is the code for the web application side of things written using Ruby on Rails.

If you're interested in contributing a scraper read our step-by-step guide to writing scrapers on our scraping platform, morph.io.

PlanningAlerts is brought to you by the OpenAustralia Foundation. It was created by Matthew Landauer and Katherine Szuminska.

Development

Install Dependencies

Checkout The Project

$ git clone https://github.com/openaustralia/planningalerts.git
$ cd planningalerts

Setup The Database

Start the application

Run The Tests

Emails in development

In development all emails are sent locally to mailcatcher. The emails can be viewed at http://localhost:1080.

Email templates are developed using Maizzle. The development workflow goes as follows:

cd maizzle
npm run dev production

Then point your browser at http://localhost:3000/rails/mailers/. As you edit the templates in maizzle/src/templates, the templates will get automatically compiled to the erb template in the main rails app tree and will also refresh the browser.

Type checking

We're using Sorbet to add type checking to Ruby which otherwise is a dynamic language. To run the type checker:

docker compose run web bin/srb

We use Shopify's tapioca gem to manage all our rbi files. We don't use bundle exec srb rbi ....

Deployment

The code is deployed using Capistrano. To deploy to production run:

bundle exec cap production deploy

This command is defined in config/deploy.rb.

Sometimes you want to deploy an alternate branch, for instance when deploying to the test stage. In this case you'll need to set the branch variable after recipies are loaded by using the --set argument instead of --set-before, e.g.

bundle exec cap staging --set branch=a-branch-i-want-to-test deploy

View more available Capistrano commands with:

bundle exec cap --tasks

Upgrading Ruby in production

Upgrading Ruby in production is an unbelievably painful process right now. I'm sorry. Let's make it simpler but in the meantime:

TODO: This section is now out of date as we now have a blue/green deploy setup that allows us to build a new image with a new ruby version and deploy it side by side with the old version and switch over between them

Note for new deploy on new servers: Make sure you run "bundle exec cap production puma:install" first. Otherwise the "puma:reload" capistrano task will fail

Update the application code

Upgrade ruby in staging

Upgrade ruby in production

During this keep a close eye on disk space on the root partition as this might get close to full

Tidy up

Adding a new authority

Someone has just written a new scraper for PlanningAlerts, woohoo! :tada: Now we need to add it to the site.

The first step is to fork their repository into the @planningalerts-scrapers organisation. This gives us control over the repository. If we didn't do that then the person could potentially inject bad data without us noticing. A more likely problem is that they go off and do something else and we have no control of the repository to fix things.

Once you've done that add it to morph and do an initial scrape to get some data. It's always a good idea to check that the scraper is getting the data we expect. Just like you'd do if someone had fixed a scraper and opened a pull request.

Speaking of pull requests, because we've forked the scraper GitHub turns off issues on forked repositories. It's a good idea to switch it back on for ours so that other people can open issues and pull requests against the @planningalerts-scrapers repository.

Now that we have a working scraper and some data we can add the new authority to PlanningAlerts. First, log into the admin backend and browse to the authorities section:

https://www.planningalerts.org.au/admin/authorities

Click New Authority in the top-right of the page. Now fill out all the details, here's what needs to go in each field:

Click Create Authority. Now scrape some applications so you can see them on the new authority page - click Scrape.

Visit the new authority page, e.g. https://www.planningalerts.org.au/authorities/bellingen/

You should see that some applications have already been collected. If not wait a few seconds and refresh the page. Once you've got some do a quick check on a few by clicking Brownse all recent applications and selecting a few. Make sure the comment form is visible (that means you set an email address).

If all looks good then thank the contributor for helping tens of thousands of people get PlanningAlerts by tweeting about it from @PlanningAlerts. It's always fun to @mention the council too, sometimes we get a RT :grinning:

We've just added @BellingenShire thanks to @LoveMyData. Another 12,886 people can now get PlanningAlerts! e.g. https://www.planningalerts.org.au/applications/898071

Contributing

Credits

Our awesome contributors can be found on the PlanningAlerts site.

This project is tested with BrowserStack.

License

GPLv2, see the LICENSE file for full details.