* CLDC-4028: Export records where a related one has updated
for instance, re-export all users in an org if the name updates
rework the export code a little to allow for this to be expressed cleanly
* CLDC-4028: Add tests
2 weeks ago
12 changed files with 331 additions and 72 deletions
LettingsLog.exportable.where("(updated_at >= :from AND updated_at <= :to) OR (values_updated_at IS NOT NULL AND values_updated_at >= :from AND values_updated_at <= :to)",params).filter_by_year(year)
SalesLog.exportable.where("(updated_at >= :from AND updated_at <= :to) OR (values_updated_at IS NOT NULL AND values_updated_at >= :from AND values_updated_at <= :to)",params).filter_by_year(year)
User.where("(updated_at >= :from AND updated_at <= :to) OR (values_updated_at IS NOT NULL AND values_updated_at >= :from AND values_updated_at <= :to)",params)
@ -147,22 +136,30 @@ Also ensure you have firefox installed
bundle exec rake db:seed
bundle exec rake db:seed
```
```
5. For Ordinance Survey related functionality, such as using the UPRN, you will need to set `OS_DATA_KEY` in your .env file. This key is shared across the team and can be found in AWS Secrets Manager.
5. Build assets once before running the app for the first time:
6. For email functionality, you will need a GOV.UK Notify API key, which is individual to you. Ask an existing team member to invite you to the "CORE Helpdesk" Notify service. Once invited, sign in and go to "API integration" to generate an API key, and set this as `GOVUK_NOTIFY_API_KEY` in your .env file.
```bash
yarn build --mode=development
```
6. For Ordinance Survey related functionality, such as using the UPRN, you will need to set `OS_DATA_KEY` in your .env file. This key is shared across the team and can be found in AWS Secrets Manager.
7. For email functionality, you will need a GOV.UK Notify API key, which is individual to you. Ask an existing team member to invite you to the "CORE Helpdesk" Notify service. Once invited, sign in and go to "API integration" to generate an API key, and set this as `GOVUK_NOTIFY_API_KEY` in your .env file.
## Running Locally
## Running Locally
### Application
### Application
Start the dev servers
Start the dev servers via one of the following methods:
a. If using RubyMine, run the "submit-social-housing-lettings-and-sales-data" Rails configuration.
a. Using Foreman:
b. Using Foreman:
```bash
```bash
./bin/dev
./bin/dev
```
```
b. Individually:
c. Individually:
Rails:
Rails:
@ -176,20 +173,18 @@ JavaScript (for hot reloading):
yarn build --mode=development --watch
yarn build --mode=development --watch
```
```
If you’re not modifying front end assets you can bundle them as a one off task:
```bash
yarn build --mode=development
```
Development mode will target the latest versions of Chrome, Firefox and Safari for transpilation while production mode will target older browsers.
Development mode will target the latest versions of Chrome, Firefox and Safari for transpilation while production mode will target older browsers.
The Rails server will start on <http://localhost:3000>.
The Rails server will start on <http://localhost:3000>.
To sign in locally, you can use any username and password from your local database. The seed task in `seeds.rb` creates users in various roles all with the password `REVIEW_APP_USER_PASSWORD` from your .env file (which has default value `password`).
To sign in locally, you can use any username and password from your local database. The seed task in `seeds.rb` creates users in various roles all with the password `REVIEW_APP_USER_PASSWORD` from your .env file (which has default value `password`).
To create any other users, you can edit the seed commands, or run similar commands in the rails console.
To create any other users, you can log in as a support user and create new users via the admin interface. Or, you can edit the seed commands, or run similar commands in the rails console.
You can also insert a new user row using SQL, but you will need to generate a correctly encrypted password. You can find the value to use for encrypted password which corresponds to the password `YOURPASSWORDHERE` using `User.new(:password => [YOURPASSWORDHERE]).encrypted_password`.
You can also insert a new user row using SQL, but you will need to generate a correctly encrypted password. You can find the value to use for encrypted password which corresponds to the password `YOURPASSWORDHERE` using `User.new(:password => [YOURPASSWORDHERE]).encrypted_password`.
### rbenv
In general, whenever needing to run a Ruby command, use `bundle exec <command>` to ensure the correct Ruby version and gemset are used. Rbenv will automatically use the correct Ruby version.
### Debugging
### Debugging
Add the line `binding.pry` to the code to pause the execution of the code at that line and open a powerful interactive console for debugging.
Add the line `binding.pry` to the code to pause the execution of the code at that line and open a powerful interactive console for debugging.
@ -219,6 +214,8 @@ More details on debugging in RubyMine can be found at <https://www.jetbrains.com
bundle exec rspec
bundle exec rspec
```
```
Or if using RubyMine, right click a spec file and select the 'Run' option.