okfn-brasil / jarbas

🎩 API for information and suspicions about reimbursements by Brazilian congresspeople
https://jarbas.serenata.ai/
296 stars 61 forks source link

Backward compatibility for URLs aiming at the Elm interface for a rec… #308

Closed cuducos closed 6 years ago

cuducos commented 6 years ago

What is the purpose of this Pull Request?

When we directed the homepage to the Dashboard we broke @RosieDaSerenata links. This PR fixes that making Jarbas backward compatible with these links.

What was done to achieve this purpose?

A JS was added to the Dashboard to check if the URL matches one of those tweeted by Rosie, if so it redirects to the proper URL.

A JS was needed because URL fragment identifiers (string after the # in the URL) are not passed to the server (even if some agents pass it, it's mostly considered a bug not a feature) and the Elm interface links are based on URL fragment identifiers.

How to test if it really works?

Access any URL such as http://localhost:8000/#/documentId/5627913 and check if it redirects to http://localhost:8000/layers/#/documentId/5627913 (there is an extra layers/ in the redirection URL path).

Who can help reviewing it?

@anaschwendler

TODO

Once this is merged @Irio can finally (re)point the DNS to the new servers.

anaschwendler commented 6 years ago

Thank @cuducos, to test this PR:

  1. Clone the project:

    $ git clone git@github.com:datasciencebr/jarbas.git
  2. Change to its folder:

    $ cd jarbas
  3. Change to @cuducos branch:

    $ git fetch origin
    $ git checkout -b cuducos-backward-compatibility-layers-url origin/cuducos-backward-compatibility-layers-url
    $ git merge master
  4. Copy the .env file:

    $ cp contrib/.env.sample .env
  5. Run the project:

    $ docker-compose up -d
    $ docker-compose run --rm django python manage.py migrate
    $ docker-compose run --rm django python manage.py reimbursements /mnt/data/reimbursements_sample.xz
    $ docker-compose run --rm django python manage.py companies /mnt/data/companies_sample.xz
    $ docker-compose run --rm django python manage.py suspicions /mnt/data/suspicions_sample.xz
    $ docker-compose run --rm django python manage.py tweets
    $ docker-compose run --rm django python manage.py searchvector
  6. Access http://localhost:8000/#/documentId/5627913: image

It redirects fine 🎉

The dashboard works fine too: image