Skip to content

Get app running locally

Vikram Ramakrishnan edited this page Sep 25, 2017 · 9 revisions

Note: These are not instructions for a production deploy and don't account for building releases or anything similar, just the minimum steps to get the app running for QA in dev mode locally.

To get the app running for testing:

  1. Clone the repo. Run mix deps.get from the root of the repo to fetch dependencies.
  2. Set some ENV Vars. Sample (replace with your DB and API URL:
export DATABASE_URL_DEV=postgresql://postgres:postgres@localhost:5432/alert_concierge_dev
export API_URL="https://dev.api.mbtace.com/"
export GUARDIAN_AUTH_KEY=abc123

Set your AWS keys (for email/sms) in prod.secret.exs, using prod.secret.exs.example as a reference.

  1. Also, navigate into apps/concierge_site/mail_inlining and run yarn install

  2. Run elixir touch_templates.exs from the root directory

  3. Make sure that your node version is on v7.10.1 and run yarn install inside the directory apps/concierge_site/assets

  4. Seed some subscriptions by changing priv/repo/seeds.exs and running mix run priv/repo/seeds/exs. A sample script create a user, subscriptions, and informed entities for those subscriptions:

alias MbtaServer.{Repo, User}
alias MbtaServer.AlertProcessor.Model.{InformedEntity, Subscription}

user = %User{
  email: "bfauble@intrepid.io",
  role: "user"
}

{:ok, user} = Repo.insert(user)

subscription_1 = Subscription.create_changeset(%Subscription{}, %{
  user_id: user.id,
  alert_priority_type: :low,
  relevant_days: [:weekday],
  start_time: ~T[04:00:00],
  end_time: ~T[12:00:00]
})

subscription_2 = Subscription.create_changeset(%Subscription{}, %{
  user_id: user.id,
  alert_priority_type: :medium,
  relevant_days: [:weekday, :sunday],
  start_time: ~T[12:00:00],
  end_time: ~T[20:00:00]
})

subscription_3 = Subscription.create_changeset(%Subscription{}, %{
  user_id: user.id,
  alert_priority_type: :high,
  relevant_days: [:weekday, :saturday],
  start_time: ~T[20:00:00],
  end_time: ~T[03:59:59]
})

{:ok, sub_1} = Repo.insert(subscription_1)
{:ok, sub_2} = Repo.insert(subscription_2)
{:ok, sub_3} = Repo.insert(subscription_3)

sixteen_bus = %InformedEntity{
  route: "16",
  route_type: 3,
  subscription_id: sub_1.id
}

fitchburg_line = %InformedEntity{
  route: "CR-Fitchburg",
  route_type: 2,
  subscription_id: sub_2.id
}

concord = %InformedEntity{
  trip: "CR-Weekday-Fall-16-414",
  stop: "Concord",
  route_type: 2,
  route: "CR-Fitchburg",
  subscription_id: sub_2.id
}

south_acton = %InformedEntity{
  trip: "CR-Weekday-Fall-16-414",
  stop: "South Acton",
  route_type: 2,
  route: "CR-Fitchburg",
  subscription_id: sub_2.id
}


red_line = %InformedEntity{
  route_type: 1,
  route: "Red",
  subscription_id: sub_3.id
}

davis = %InformedEntity{
  route_type: 1,
  route: "Red",
  stop: "place-davis",
  subscription_id: sub_3.id
}

harvard = %InformedEntity{
  route_type: 1,
  route: "Red",
  stop: "place-harsq",
  subscription_id: sub_3.id
}

Repo.insert(sixteen_bus)
Repo.insert(fitchburg_line)
Repo.insert(concord)
Repo.insert(south_acton)
Repo.insert(red_line)
Repo.insert(davis)
Repo.insert(harvard)
  1. Create, Migrate, Seed DB: mix ecto.setup

  2. Start the app with mix phx.server. This will start up the alert parser and should begin processing alerts against the seeded subscriptions