Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README following removal of Airtable code. #105

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 31 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,53 @@

This application provides a Register of Information sharing agreements under chapters 1, 2, 3 and 4 of part 5 of the Digital Economy Act 2017.

## Airtable data
## Data source

The source data is stored in an Airtable base store. The specific base is specified via a
[Personal Access Token](https://airtable.com/developers/web/api/authentication).
See the AirTableApi service object for how this token is stored.
The data source is a [rAPId](https://rapid.readthedocs.io/) application. For access the following credentials need to
be passed into the matching environment variables:

| Credential | Environment Variable |
| ------------- | -------------------- |
| Client ID | RAPID_CLIENT_ID |
| Client Name | RAPID_CLIENT_NAME |
| Client Secret | RAPID_CLIENT_SECRET |

### Local store

The main models in this application inherit from an `AirTable` class and are types of that class. So their data is
stored in a single table: `air_tables`.
The main models in this application inherit from a `DataTable` class and are types of that class. So their data is
stored in a single table: `data_tables`.

Most of the data specific to a particular model is stored in the `fields` attribute. This is a JSON object that
holds the original data pulled from the Airtable source. This arrangement was chosen to lesson the likelihood that
a change in the Airtable would break the application. If a field in the source Airtable is changed (specifically
holds the original data pulled from the data source. This arrangement was chosen to lesson the likelihood that
a change in the source data would break the application. If a field in the source is changed (specifically
renamed) the data will no longer be displayed, but it should not break the application.

### Population

An Airtable model can be populated by calling its class method `populate`. This method is defined on the root `AirTable`
A data model can be populated by calling its class method `populate`. This method is defined on the root `DataTable`
class.

Join tables are used to manage the associated between models. These have their own `populate` class methods which
are defined on each of the models

Database seeding runs `populate` of all these models and populates their tables:
Database seeding runs `populate` on all these models and populates their tables:

rails db:seed

If the database is empty, this will populate the tables with the current data in the Airtable. If the database
is already populated, this process will update the data to match the current data. This includes deleting any
records that have been deleted from Airtable.
If the database is empty, this will populate the tables with the current data in from the data source.

If the database is already populated, this process will update the data to match the current data. This includes deleting any records that have been deleted from the data source.

Seeding also rebuilds the search database.

In production this task is run via a cron job and ensures that the application is regularly synchronised with
the source data.

In staging a button is available on the home page that allows the population task to be triggered from the home page.
This task is carried out via a delayed job and for it to run there must be a worker running. This is done so that the
web interface is not frozen while the population task is running. In production, the cron job runs in a separate
space so does not need to be run via delayed job.

### Search

Searching is provided by the Postgres search tool PgSearch. See the Search Controller for details.
Expand All @@ -47,7 +59,10 @@ Before this application will run successfully locally, the following actions wil

- Obtain the current master.key and save it in `/config`. Or set up a new Rails credentials containing:

airtable_api_key: [Airetable Personal Access Token]
rapid:
client_id: [a client id]
client_name: [a client name]
client_secret: [a client secret]

- Run `yarn` to set up the JavaScript environment
- Run 'rake dartsass:build' to build application.css
Expand All @@ -62,11 +77,8 @@ This application is hosted in Heroku for staging, and is set to deploy automatic

## Production

This application is containerised via docker, for use in production. To run the container use:

AIRTABLE_API_KEY=[airtable_api_key] RAILS_MASTER_KEY=[random uuid] docker-compose up --build

Where `[airtable_api_key]` is the airtable Personal Access Token (see above)
This application is hosted in Heroku for production. Promotion of merged code is done manually. The staging and
production instances are within a pipeline (cddo-dea-register-pipeline) and both instances can be managed from within the pipeline.

## Contacts

Expand Down
Loading