Browse Source

Minor changes

pull/7/head
Victor Roest 2 years ago
parent
commit
140683cc34
Signed by: 0x76 GPG Key ID: A3923C699D1A3BDA
  1. 4
      .iex.exs
  2. 9
      README.md
  3. 2
      config/prod.exs
  4. 4
      lib/dps/poem.ex
  5. 16
      priv/repo/seeds.exs

4
.iex.exs

@ -1,4 +1,2 @@
alias Dps.Repo
alias Dps.Author
alias Dps.Poem
alias Dps.{Repo, Author, Poem}
import Ecto.Query

9
README.md

@ -1 +1,10 @@
# Poems
A minimalistic website to store and view my favourite poems.
## Development
To run dps in dev mode:
```bash
mix postgres start # Start local postgres db inside a docker container
mix.ecto.reset # Migrate and seed the database
mix phx.server # Start the live reload server
```

2
config/prod.exs

@ -10,7 +10,7 @@ import Config
# which you should run after static files are built and
# before starting your production server.
config :dps, DpsWeb.Endpoint,
url: [host: "example.com", port: 80],
url: [host: "poems.xirion.net", port: 443],
cache_static_manifest: "priv/static/cache_manifest.json"
# Do not print debug messages in production

4
lib/dps/poem.ex

@ -35,7 +35,9 @@ defmodule Dps.Poem.Query do
end
def get_all_poems_by_author(author_id) do
from(p in Poem, select: %Poem{id: p.id, author_id: p.author_id, title: p.title}, where: p.author_id == ^author_id)
from(p in Poem,
select: %Poem{id: p.id, author_id: p.author_id, title: p.title},
where: p.author_id == ^author_id)
|> Repo.all()
end

16
priv/repo/seeds.exs

@ -1,19 +1,11 @@
# Script for populating the database. You can run it as:
#
# mix run priv/repo/seeds.exs
#
# Inside the script, you can read and write to any of your
# repositories directly:
#
# Dps.Repo.insert!(%Dps.SomeSchema{})
#
# We recommend using the bang functions (`insert!`, `update!`
# and so on) as they will fail if something goes wrong.
# Script for populating the database.
alias Dps.Repo
alias Dps.Poem
alias Dps.Author
coleridge = Repo.insert!(%Author{name: "Samuel Taylor Coleridge"}).id
robert_frost = Repo.insert!(%Author{name: "Robert Frost"}).id
Repo.insert!(%Poem{
author_id: coleridge,
@ -76,8 +68,6 @@ And close your eyes with holy dread
For he on honey-dew hath fed,
And drunk the milk of Paradise."})
robert_frost = Repo.insert!(%Author{name: "Robert Frost"}).id
Repo.insert!(%Poem{
author_id: robert_frost,
title: "The Road Not Taken",

Loading…
Cancel
Save