Programming Phoenix LiveView - Version B5.0
On Chapter 3 - Page 78, the beginning of the page has this code here:
@doc """
Maybe it is missing to put the Pento context before Catalog.Product.Query?
"""
defmodule Catalog.Product.Query do
...
def base_product_query, do: Product
def cheaper_than(query, price), do: from in query, where...
def cheap_product_skus(price)
base_product_query()
|> chaper_than(price)
|> skus
end
...
end
And for the code almost to the bottom, has some typos. Like:
defmodule Pento.Catalog do
alias Catalog.Product.Query
alias Pento.Repo
def run_query(query) do
{:ok, list} = Repo.all(query)
list
end
def send_sale_skus(query) do
query
|> Product.cheap_product_skus(25.00) # Typo: Query.cheap_product_skus(25.00)
|> run_query
|> Service.send_bargains # Question: the name of the module it is only Service?
end
end
Also, for the next page 79, has more typos too, like:
defmodule Pento.Catalog do
alias Catalog.Product.Query
alias Pento.Repo
@doc """
For the Repo.all API, has only three options:
1. Empty List without any items.
2. List with one or more items.
3. Query doesn't work and raise an error.
"""
def run_query(query) do
Repo.all(query)
end
def send_sale_skus(query) do
query
|> Product.cheap_product_skus(25.00) # Typo: Query.cheap_product_skus(25.00)
|> run_query
end
def send_sale_skus(query)
with {:ok, products} <- send_sale_skus(query), # this line of code here, never pattern matching
{:ok, response} <- Service.send_bargains(products) do # when this line of code it fails? Returns as a tuple with {:error, reason} ?
response
else
# if some error or cas doesn't pattern match in with conditions it will failure here a raise an error with unclause matching.
{:error, reason} ->
IO.puts "Error sending sale skus: #{reason}"
end
end
end
After words this is my feedback even these code as an example, and not intended to use. Besides, I use common comments as #
, and some others I use @doc
to get my point of view.
Popular Pragprog topics

When I try the command to create a pair of migration files I get an error.
user=> (create-migration "guestbook")
Execution ...
New

Hi,
build fails on:
bracket-lib = “~0.8.1”
when running on Mac Mini M1 Rust version 1.5.0:
Compiling winit v0.22.2
error[E0308]: mi...
New

Dear Sophie.
I tried to do the “Authorization” exercise and have two questions:
When trying to plug in an email-service, I found the ...
New

Hello! Thanks for the great book.
I was attempting the Trie (chap 17) exercises and for number 4 the solution provided for the autocorre...
New

When trying to generate the protobuf .go file, I receive this error:
Unknown flag: --go_opt
libprotoc 3.12.3
MacOS 11.3.1
Googling ...
New

I’m not quite sure what’s going on here, but I’m unable to have to containers successfully complete the Readiness/Liveness checks. I’m im...
New

Hi,
I am getting an error I cannot figure out on my test.
I have what I think is the exact code from the book, other than I changed “us...
New

I am using Android Studio Chipmunk | 2021.2.1 Patch 2
Build #AI-212.5712.43.2112.8815526, built on July 10, 2022
Runtime version: 11.0....
New

@mfazio23
I’ve applied the changes from Chapter 5 of the book and everything builds correctly and runs. But, when I try to start a game,...
New

From page 13:
On Python 3.7, you can install the libraries with pip by running these commands inside a Python venv using Visual Studio ...
New
Other popular topics

What chair do you have while working… and why?
Is there a ‘best’ type of chair or working position for developers?
New

New

I’m thinking of buying a monitor that I can rotate to use as a vertical monitor?
Also, I want to know if someone is using it for program...
New
New
New

Oh just spent so much time on this to discover now that RancherOS is in end of life but Rancher is refusing to mark the Github repo as su...
New

Crystal recently reached version 1. I had been following it for awhile but never got to really learn it. Most languages I picked up out o...
New

Author Spotlight: James Stanier (@jstanier)
James Stanier, author of Effective Remote Work , discusses how to rethink the office as we...
New

Author Spotlight: Jamis Buck (@jamis)
This month, we have the pleasure of spotlighting author Jamis Buck, who has written Mazes for P...
New

Chris Seaton, the creator of TruffleRuby has died. It appears from suicide :cry:
He left this note on Twitter on the weekend:
And one...
New
Latest in Pragprog
Latest (all)
Categories:
My Saved Portals
-
None saved yet
Popular Portals
- /elixir
- /opensuse
- /rust
- /kotlin
- /ruby
- /erlang
- /python
- /clojure
- /react
- /quarkus
- /go
- /vapor
- /v
- /react-native
- /wasm
- /security
- /django
- /nodejs
- /centos
- /haskell
- /rails
- /fable
- /gleam
- /swift
- /js
- /deno
- /assemblyscript
- /tailwind
- /laravel
- /symfony
- /phoenix
- /crystal
- /typescript
- /debian
- /adonisjs
- /julia
- /arch-linux
- /svelte
- /spring
- /preact
- /flutter
- /c-plus-plus
- /actix
- /java
- /angular
- /ocaml
- /zig
- /kubuntu
- /scala
- /zotonic
- /vim
- /rocky
- /lisp
- /html
- /keyboards
- /vuejs
- /nim
- /emacs
- /nerves
- /elm