No description
Find a file
2022-11-25 03:50:17 -08:00
.github/workflows Update github action to use node v18 2022-11-03 14:31:47 -07:00
app Make utility method private 2022-11-25 03:50:17 -08:00
bin Add benchmarks to survey and admin data items. Remove them from measures. Modify seeder 2021-12-28 14:10:34 +01:00
config Add key derivation salt 2022-08-25 22:29:35 -07:00
data Fix more malformed csv errors 2022-11-25 03:09:00 -08:00
db remove gender from student table 2022-10-22 15:57:52 -07:00
doc Add architectural decision record about response ids for boston being consecutive integers 2022-09-05 12:09:18 -07:00
lib add tasks to upload single year of data 2022-11-23 11:01:44 -08:00
log first commit 2017-02-23 12:52:56 -05:00
public remove fontawesome symlinked directory from public folder 2021-12-17 14:09:02 +01:00
scripts run tests in parallel in CI 2022-08-20 15:09:59 -07:00
spec Add selector for all data 2022-11-18 08:20:26 -08:00
tmp first commit 2017-02-23 12:52:56 -05:00
vendor/assets first commit 2017-02-23 12:52:56 -05:00
.editorconfig we have a gauge! next up, let's style the page 2021-10-01 13:32:10 -04:00
.erb-lint.yml set up formatters 2022-07-15 16:54:59 -07:00
.gitignore Ignore spec output file 2022-02-01 15:27:15 +01:00
.prettierrc Add missing javascript dependencies to package.json. Move javascripts files to app/javascript. Add first javascript test. Change test mode 2021-10-16 00:03:44 +02:00
.prettierrc.json Create ui for data filters. Add listeners to direct to the correct url. Update ui based on the list of selected params 2022-07-26 06:52:50 -07:00
.reek.yml continue refactoring 2022-07-13 15:32:48 -07:00
.rspec Add parallel tests gem 2022-01-31 19:59:24 +01:00
.rubocop.yml Create ui for data filters. Add listeners to direct to the correct url. Update ui based on the list of selected params 2022-07-26 06:52:50 -07:00
.ruby-version Update ruby version file to match version in Gemfile 2022-05-03 11:17:48 -07:00
.solargraph.yml import students 2022-07-29 15:34:56 -07:00
babel.config.js Set up jest with babel. Add failing test to see if it passes CI 2021-10-16 00:03:44 +02:00
CHANGELOG.md Updated changelog 2022-11-23 07:42:54 -08:00
config.ru first commit 2017-02-23 12:52:56 -05:00
Gemfile Add admin data for 4D. Finishes #182818489 and #182793402 2022-08-30 21:46:23 -07:00
Gemfile.lock Update dependencies to patch security vulnerabilities 2022-11-03 17:12:57 -07:00
package.json specify node version 2022-11-02 16:46:20 -07:00
Procfile Run migrations when deploying to Heroku 2021-11-02 09:27:14 -04:00
Procfile.dev Add css bundling (again!) 2021-11-17 10:52:35 -05:00
Rakefile Moved rspec-rails declaration to development/test section of Gemfile. now runs tests without having to alter Rakefile. 2022-02-03 16:31:18 +01:00
README.md Load student data for all years and calculate race scores for all 2022-08-20 15:07:15 -07:00
yarn-error.log Switch from sprockets to cssbundling for bundling css assets. 2021-10-23 19:59:34 +02:00
yarn.lock Address bug related to story #182855028 2022-07-29 16:04:43 -07:00

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.

Live app: https://mciea-dashboard.herokuapp.com/ Live dashboard: 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

https://www.postgresql.org/download/

On linux, if you run into problems creating the postgres database, edit /etc/postgresql/13/main/pg_hba.conf. Change the connection method of IPv4 and IPv6 connections from md5 to trust.

# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 trust

Once postgres is installed and running, install the required gems and then migrate the database.

bundle install
bundle exec rake db:create db:schema:load db:seed

Install the javascript dependencies

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
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
stimulus Create javascript controllers
turbo-rails Manages what gets rendered on the frontend and when
redis Caching system
jsbundling-rails Bundle javascript asssets
cssbundling-rails Bundle css assets

External APIs

None yet. Hoping to integrate with Powerschool and Aspen for school administrative data.

Javascript

Esbuild is used as the javascript bundler. Scripts for esbuild are defined in package.json e.g. yarn build. This script will run if in development with bin/dev. The javascript testing library is jest. Manually run test with yarn test. Javascript tests will also run with bundle exec rake.

Stimulus is installed. Create a stimulus controller with ./bin/rails generate stimulus [controller]. If you create a stimulus controller manually, you can add it to index.js with the command stimulus:manifest:update.

css

Bootstrap 5

Loading Data

Loading Survey Item Responses

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:

# 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 exec rake data:load_survey_responses

For convenience, you can use the following script for loading data on Heroku:

# on heroku staging environment
$ ./scripts/load_survey_responses_on_heroku beta

# on heroku production environment
$ ./scripts/load_survey_responses_on_heroku dashboard

There is also an example one-off task to load a single csv at a time.

bundle exec rake one_off:load_2018_19_student_responses

Loading Admin Data Values

Loading admin data is similar to loading survey item responses. Run the one of the following scripts to load admin data to a selected environment.

# locally
$ bundle exec rake data:load_admin_data

# on heroku staging environment
$ heroku run:detached -a mciea-beta bundle exec rake data:load_admin_data

# on heroku production environment
$ heroku run:detached -a mciea-dashboard bundle exec rake data:load_admin_data

Load Response Rates

Many parts of the site rely on the response rate table being populated. The response rate is taken into account when determining if there is sufficient data to show

# locally
$ bundle exec rake data:reset_response_rates

# on heroku staging environment
$ heroku run:detached -a mciea-beta bundle exec rake data:reset_response_rates

# on heroku production environment
$ heroku run:detached -a mciea-dashboard bundle exec rake data:reset_response_rates

Load Student demographic information

Student demographic information is needed for the Analyze page disagregation

# locally
$ bundle exec rake data:load_students

# on heroku staging environment
$ heroku run:detached -a mciea-beta bundle exec rake data:load_students

# on heroku production environment
$ heroku run:detached -a mciea-dashboard bundle exec rake data:load_students

Load scores for each race

For performance, the scores for an individual race must be precalculated. Make sure to load response rates, and student demographic information before recaculating scores by race

# locally
$ bundle exec rake data:reset_race_scores

# on heroku staging environment
$ heroku run:detached -a mciea-beta bundle exec rake data:reset_race_scores

# on heroku production environment
$ heroku run:detached -a mciea-dashboard bundle exec rake data:reset_race_scores

Running tests

Single threaded test execution

Prepare the test database.

bundle exec rake db:test:prepare

If you need to look at the rails console for the test environment

RAILS_ENV=test rails c

Run the tests

bundle exec rake

Parallel test execution

The parallel tests gem is installed. It's optional to use.

Set the TEST_ENV_NUMBER environment variable. For example, add this line to your .bashrc

export TEST_ENV_NUMBER="20"

Create the additional databases

bundle exec rake parallel:create

Run the tests in parallel

bundle exec rake parallel:spec

Run the tests with a specific number of processes

bundle exec rake parallel:spec[5]

Viewing test coverage

xdg-open coverage/index.html

Javascript tests

Run the javascript tests

yarn test

Connecting to Heroku git

To add the heroku remote repository for beta run git remote add beta https://git.heroku.com/mciea-beta.git

To add the heroku remote repository for production run git remote add dashboard https://git.heroku.com/mciea-dashboard.git

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

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.

yarn build --watch

Start the puma web server

bin/rails s