You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
181 lines
4.9 KiB
181 lines
4.9 KiB
# edcontext
|
|
|
|
This project contains three pieces:
|
|
|
|
- A webapp for visualizing and understanding MCIEA survey data
|
|
- Tasks for processing and indexing raw survey data
|
|
- Experimental work to conduct survey samples via text message
|
|
|
|
This is a Rails project, deployed on Heroku.
|
|
|
|
## Site links
|
|
|
|
Live app: [https://mciea-dashboard.herokuapp.com/](https://mciea-dashboard.herokuapp.com/)
|
|
Live dashboard: [http://mciea-dashboard.herokuapp.com/districts/winchester/schools/winchester-high-school/dashboard?year=2020-21](http://mciea-dashboard.herokuapp.com/districts/winchester/schools/winchester-high-school/dashboard?year=2020-21)
|
|
|
|
## Local development
|
|
|
|
Install Postgres and running first.
|
|
|
|
(MacOS, Optional), you can use Homebrew:
|
|
|
|
```
|
|
brew install postgres
|
|
brew services start postgresql
|
|
```
|
|
|
|
Linux:
|
|
|
|
Install postgres. Known working version is version 13
|
|
|
|
```bash
|
|
https://www.postgresql.org/download/
|
|
```
|
|
|
|
Once postgres is installed and running, install the required gems and then migrate the database.
|
|
|
|
```bash
|
|
bundle install
|
|
bundle exec rake db:create db:migrate db:seed
|
|
```
|
|
|
|
Install the javascript dependencies
|
|
|
|
```bash
|
|
yarn install
|
|
```
|
|
|
|
At this point you can run the app and login. There won't be any data yet though; keep reading!
|
|
|
|
The seed file populates the following tables
|
|
|
|
| Name | Description |
|
|
| ------------ | ---------------------------------- |
|
|
| School | School ids are only unique to their district. More than one school has an id of 1 |
|
|
| District | Districts and schools have attached slugs. We find search for these models by their slugs |
|
|
| SqmCategory | The legacy name here is Category. It still exits in the database. We wanted the freedom to make changes and still preserve the legacy site until the end of the engagement. |
|
|
| Measure | In the bar graph measures represent a single bar |
|
|
| SurveyItem | This table has an attribute `prompt` that is the question asked |
|
|
|
|
SurveyItemResponses does not get populated at this stage.
|
|
|
|
### Database
|
|
|
|
Postgres
|
|
|
|
### Gems
|
|
|
|
| Name | Description |
|
|
| ------------ | ---------------------------------- |
|
|
| puma | webserver |
|
|
| pg | postgres |
|
|
| sassc-rails | sass compiler |
|
|
| jquery-rails | legacy, allows use of jquery |
|
|
| jbuilder | legacy, build json objects |
|
|
| haml | legacy, write views in haml syntax |
|
|
| bootstrap | css framework |
|
|
| newrelic_rpm | legacy?, application monitoring |
|
|
| devise | authentication |
|
|
| omniauth | authentication |
|
|
| twilio-ruby | legacy, text messaging |
|
|
| activerecord-import | faster database imports |
|
|
|
|
### External APIs
|
|
|
|
None yet. Hoping to integrate with Powerschool and Aspen for school administrative data.
|
|
|
|
### Javascript libraries
|
|
|
|
Esbuild is used as the javascript bundler. The javascript testing library is jest.
|
|
|
|
### css
|
|
|
|
Bootstrap 5
|
|
|
|
## Loading Data
|
|
|
|
SurveyItemResponses is the most important table to understand. SurveyItemResponses is the data that will change year to year and makes up the majority of the database records. Roughly 500,000 SurveyItemResponses per year.
|
|
|
|
Some notes:
|
|
|
|
- The data loading task assumes that the CSV files live in the `#{RAILS_ROOT}/data/survey_responses` directory
|
|
- The data loading task is idempotent, i.e. it can be run multiple times without duplicating previously-ingested data
|
|
|
|
How to run the data loading task:
|
|
|
|
```bash
|
|
# locally
|
|
$ bundle exec rake data:load_survey_responses
|
|
|
|
# on heroku staging environment
|
|
$ heroku run:detached -a mciea-beta bundle exec rake data:load_survey_responses
|
|
|
|
# on heroku production environment
|
|
$ heroku run:detached -a mciea-dashboard bundle rake data:load_survey_responses
|
|
```
|
|
|
|
For convenience, you can use the following script for loading data on Heroku:
|
|
|
|
```bash
|
|
# on heroku staging environment
|
|
$ ./scripts/load_survey_responses_on_heroku beta
|
|
|
|
# on heroku production environment
|
|
$ ./scripts/load_survey_responses_on_heroku dashboard
|
|
```
|
|
|
|
## Running tests
|
|
|
|
Prepare the test database.
|
|
|
|
```bash
|
|
bundle exec rake db:test:prepare
|
|
```
|
|
|
|
If you need to look at the rails console for the test environment
|
|
|
|
```bash
|
|
RAILS_ENV=test rails c
|
|
```
|
|
|
|
```bash
|
|
bundle exec rake
|
|
```
|
|
|
|
Run javascript tests
|
|
|
|
```bash
|
|
yarn test
|
|
```
|
|
|
|
## Continuous Integration
|
|
|
|
Pushing commits to the main branch triggers auto-deployment to the staging environment.
|
|
Use the ship-it script from the main branch when you're ready to deploy to staging
|
|
|
|
```bash
|
|
scripts/ship-it.sh
|
|
```
|
|
|
|
Deployments to production must be done through the Heroku web interface or via the Heroku command line
|
|
|
|
## Running the development server
|
|
|
|
Start esbuild for dynamic compilation of javascript assets.
|
|
|
|
```bash
|
|
yarn build --watch
|
|
```
|
|
|
|
Start cssbundling AND esbuild for dynamic compilation of javascript and css assets.
|
|
|
|
```bash
|
|
scripts/bundling.sh
|
|
```
|
|
|
|
Start the puma web server
|
|
|
|
```bash
|
|
bin/rails s
|
|
```
|