Skip to content

Commit

Permalink
Store update
Browse files Browse the repository at this point in the history
  • Loading branch information
Kalimaha committed Apr 21, 2018
1 parent 3a302e8 commit d041163
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Expand Up @@ -15,6 +15,8 @@ RUN mix local.rebar --force
# Set work directory
WORKDIR /app

# Install dependencies
RUN mix deps.get

# Expose Phoenix's default port
EXPOSE 4000

3 changes: 3 additions & 0 deletions README.md
Expand Up @@ -12,10 +12,13 @@ This project uses Docker and Docker compose for development. To build the images
docker-compose build
```

??? -> "mix deps.get"

The first time you will need to create the DB:

```
docker-compose run web mix ecto.create
docker-compose run web mix ecto.migrate
```

Then, to start the app:
Expand Down
3 changes: 1 addition & 2 deletions priv/repo/migrations/20180330055909_add_updates_table.exs
Expand Up @@ -8,8 +8,7 @@ defmodule WeatherStationManager.Repo.Migrations.AddUpdatesTable do
add :lon, :float
add :temperature, :float

timestamps
timestamps()
end
end
end

4 changes: 3 additions & 1 deletion web/stages/updates_db_consumer.ex
Expand Up @@ -3,6 +3,8 @@ defmodule UpdatesDBConsumer do

require Logger

alias WeatherStationManager.UpdatesRepository

def start_link() do
GenStage.start_link(__MODULE__, :ok)
end
Expand All @@ -13,7 +15,7 @@ defmodule UpdatesDBConsumer do

def handle_events(events, _from, state) do
Logger.debug "[STAGE] - Write to DB: START"
Enum.each events, fn(_spam) -> Logger.debug "processing SQL..." end
Enum.each events, fn(event) -> UpdatesRepository.save event end
Logger.debug "[STAGE] - Write to DB: DONE"

{ :noreply, [], state }
Expand Down

0 comments on commit d041163

Please sign in to comment.