git clone git@github.com:StreamKey/streamkey-dashboard.git
yarn
- create
.env
, useenv.template
as a reference
We use the Sequelize ORM over Postgresql.
To run a local DB in a docker container, make sure you're logged in to docker with docker login
and then run yarn db:install
. It will launch a pg instance on local port 5444 with the user postgres/mysecretpassword.
Run yarn db:start
if this container exists and is stopped.
To remove the container run yarn db:rm
.
Connect to the DB:
docker run -it --rm --link streamkey-postgres:postgres postgres psql -h postgres -U postgres
Sync DB with:
yarn sequelize db:migrate --config src/DB/config.js
Undo migration:
yarn sequelize db:migrate:undo --config src/DB/config.js
Add a DB model and a migration:
yarn sequelize model:generate --name User --attributes firstName:string,lastName:string
Then edit the src/DB/migrations/xxx-create.user.js
and src/DB/models/user.js
files.
Finally add your model to the DB class and use it like this (table name is prular):
await DB.models.Users.create({ ... })
Add a DB migration to an existing model:
yarn sequelize migration:generate --name User
Then edit the new migration in src/DB/migrations
and provide up/down methods using the QueryInterface API.
Example of SQL query:
docker run -it --rm --link streamkey-postgres:postgres postgres psql -h postgres -U postgres -d postgres -t -A -F"," -c "SELECT * FROM \"SspData\" WHERE date='2018-09-14' AND key='beachfront'"
yarn start
- Create new fetch file at
src/workers/scrapeDaily/[AS|SSP]/
- Store credentials in
.env
and add variable names toenv.template
- Add partner to
src/workers/scrapeDaily/[GetASData|GetSSPData]
- Add partner key to
src/workers/scrapeDaily/fetchData
- Add partner key to
src/workers/scrapeDaily/createReport
- Add partner to
src/components/Utils
- Add partner key to
src/api/controllers/Report/groupBySspAs
- Update server crontab
yarn test
- make sure all works locally (yarn build && NODE_ENV=production node build/server.js)
yarn test
- bump version
- push to
master
yarn shipit production deploy
yarn shipit production install
yarn shipit production restart
If something goes wrong, revert to previous deployment with:
yarn shipit production rollback
yarn shipit production restart