This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
children_changes_params = [ | |
%{"id" => 1, "age" => 30, "address" => "Los Angeles"}, | |
%{"id" => 2, "age" => 28, "address" => "Manila"}, | |
%{"id" => 3, "age" => 37, "address" => "Toulouse"} | |
] | |
multi = | |
Enum.reduce(children_changes_params, Ecto.Multi.new(), fn %{"id" => id} = child_params, | |
multi -> | |
with {:ok, child} <- Repo.find(Child, id) do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ecto.Query | |
... | |
defmacro store_items_not_exist(store_items_table_name, store_id, item_name) do | |
args = [ | |
"NOT EXISTS (SELECT * FROM #{store_items_table_name} item WHERE item.store_id = ? AND item.name == ?)", | |
store_id, | |
item_name | |
] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ecto.Query | |
... | |
from(store in Store, | |
where: fragment("NOT EXISTS (SELECT * FROM APPLIANCES item WHERE item.store_id == ? AND item.name == 'VCR player')", store.id), | |
where: fragment("NOT EXISTS (SELECT * FROM GAME_CONSOLES item WHERE item.store_id == ? AND item.name == 'Sega Genesis console')", store.id), | |
where: fragment("NOT EXISTS (SELECT * FROM DELIVERY_TRUCKS truck WHERE truck.store_id == ?)", store.id) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ecto.Query | |
... | |
from(store in Store, | |
where: fragment("NOT EXISTS (SELECT * FROM APPLIANCES item WHERE item.store_id == ? AND item.name == 'VCR player')", store.id), | |
where: fragment("NOT EXISTS (SELECT * FROM GAME_CONSOLES item WHERE item.store_id == ? AND item.name == 'Sega Genesis console')", store.id) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def pp(what_to_print, debug_message \\ "") do | |
IO.puts("#{IO.ANSI.yellow()} START #{debug_message} ====================") | |
IO.puts(IO.ANSI.yellow() <> inspect(what_to_print, pretty: true, limit: :infinity)) | |
IO.puts("#{IO.ANSI.yellow()} END #{debug_message} ====================\n\n") | |
what_to_print | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe "make COLD dishes when seasoning available" do | |
setup [:setup_cold_dish, :set_seasoning] | |
test "", context do | |
assert add_seasoning | |
end | |
end | |
describe "make COLD dishes when extra protein available" do | |
setup [:setup_cold_dish, :set_protein] | |
test "", context do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe "make COLD dishes from left over when seasoning available" do | |
setup [:setup_cold_dish, :set_seasoning] | |
test "", context do | |
assert add_seasoning | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe "make COLD dishes from left over" do | |
setup [:setup_cold_dish] | |
test "", context do | |
... | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defp setup_cold_dish(%{size: size}) do | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defp setup_cold_dishes(context) do | |
temp = 35 | |
size = if context.size, do: size, else: :small | |
dish = set_temperature(temp) | |
|> set_size(size) | |
|> set_time_in_fridge(:15_hours) | |
|> build_dish | |
%{temp: temp, size: size, cold_dish: dish} | |
end |
NewerOlder