Skip to content

Commit

Permalink
remove dbg() #165
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonic committed Nov 1, 2023
1 parent a58edec commit 6aae78a
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 25 deletions.
6 changes: 2 additions & 4 deletions lib/app/list.ex
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ defmodule App.List do
`add_item_to_list/3` adds the `item.cid` to the `list.cid` for the given `person_id`.
"""
def add_item_to_list(item_cid, list_cid, person_id) do
list = get_list_by_cid!(list_cid) |> dbg()
prev_seq = get_list_seq(list) |> dbg()
list = get_list_by_cid!(list_cid)
prev_seq = get_list_seq(list)
seq = [item_cid | prev_seq] |> Enum.join(",")
update_list(list, %{seq: seq, person_id: person_id})
end
Expand Down Expand Up @@ -251,9 +251,7 @@ defmodule App.List do
"""
def add_all_items_to_all_list_for_person_id(person_id) do
all_list = App.List.get_all_list_for_person(person_id)
# dbg(all_list)
all_items = App.Item.all_items_for_person(person_id)
# dbg(all_items)
prev_seq = get_list_seq(all_list)
# Add add each `item.id` to the sequence of item ids:
seq =
Expand Down
1 change: 0 additions & 1 deletion lib/app_web/controllers/list_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ defmodule AppWeb.ListController do
end

def create(conn, %{"list" => list_params}) do
dbg(list_params)
person_id = conn.assigns[:person][:id] || 0

list_params =
Expand Down
25 changes: 14 additions & 11 deletions lib/app_web/live/app_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ defmodule AppWeb.AppLive do
defp get_list_name(assigns), do: assigns[:list_name]

defp list_cid_from_url_params(params) do
dbg(Map.get(params, "list_cid"))
if Map.has_key?(params, "list_cid"), do: Map.get(params, "list_cid", nil)
end

Expand All @@ -29,18 +28,21 @@ defmodule AppWeb.AppLive do
person_id = Person.get_person_id(socket.assigns)

custom_list = list_cid_from_url_params(params)
list_cid = if custom_list == nil do
# Create or Get the "all" list for the person_id
all_list = App.List.get_all_list_for_person(person_id)

# Temporary function to add All *existing* items to the "All" list:
App.List.add_all_items_to_all_list_for_person_id(person_id)
list_cid =
if custom_list == nil do
# Create or Get the "all" list for the person_id
all_list = App.List.get_all_list_for_person(person_id)

# Temporary function to add All *existing* items to the "All" list:
App.List.add_all_items_to_all_list_for_person_id(person_id)

# return the "all" list cid
all_list.cid
else
custom_list

Check warning on line 43 in lib/app_web/live/app_live.ex

View check run for this annotation

Codecov / codecov/patch

lib/app_web/live/app_live.ex#L43

Added line #L43 was not covered by tests
end

# return the "all" list cid
all_list.cid
else
custom_list
end
lists = App.List.get_lists_for_person(person_id)
list = Enum.find(lists, fn list -> list.cid == list_cid end)

Expand Down Expand Up @@ -94,6 +96,7 @@ defmodule AppWeb.AppLive do
# Add this newly created `item` to the list current list:
list_cid = get_list_cid(socket.assigns)
list_name = get_list_name(socket.assigns)

if list_name !== "all" do
App.List.add_item_to_list(item.cid, list_cid, person_id)

Check warning on line 101 in lib/app_web/live/app_live.ex

View check run for this annotation

Codecov / codecov/patch

lib/app_web/live/app_live.ex#L101

Added line #L101 was not covered by tests
end
Expand Down
11 changes: 6 additions & 5 deletions lib/app_web/templates/nav/nav.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@

<div class="flex flex-1 items-center justify-center">
<div class="flex flex-shrink-0 items-center">
<%= if @custom_list do %>
<h1 class="text-white text-2xl"> <%= list_name(@list_name) %></h1>
<% else %> <!-- show the @dwyl logo and link to root -->
<%= if @custom_list do %>
<h1 class="text-white text-2xl"><%= list_name(@list_name) %></h1>
<% else %>
<!-- show the @dwyl logo and link to root -->
<a href="/" class="flex items-center">
<img
src="https://dwyl.com/img/common/dwyl-heart-only-logo.png"
Expand All @@ -70,9 +71,9 @@
alt="dwyl logo"
/>
</a>
<% end %>
</div>
<% end %>
</div>
</div>

<div class="absolute inset-y-0 right-0 flex items-center">
<!-- Mobile menu button-->
Expand Down
1 change: 0 additions & 1 deletion lib/app_web/views/list_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ defmodule AppWeb.ListView do
use AppWeb, :view

def list_item_count(list) do
# dbg(list)
if list.seq == nil do
"0"
else
Expand Down
1 change: 0 additions & 1 deletion test/app/item_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ defmodule App.ItemTest do
assert {:ok, %{model: item}} =
Item.create_item(@valid_attrs)

# dbg(item)
assert item.text == @valid_attrs.text

inserted_item = List.first(Item.get_items())
Expand Down
1 change: 0 additions & 1 deletion test/app_web/live/app_live_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,6 @@ defmodule AppWeb.AppLiveTest do
# Update list_item.seq:
{:ok, %{model: list}} = App.List.update_list_seq(list.cid, person_id, "#{item.cid},#{item3.cid},#{item2.cid}")
new_seq = list.seq |> String.split(",")
# dbg(new_seq)
pos2 = Enum.find_index(new_seq, fn x -> x == "#{item2.cid}" end)
pos3 = Enum.find_index(new_seq, fn x -> x == "#{item3.cid}" end)
assert pos3 < pos2
Expand Down
2 changes: 1 addition & 1 deletion test/app_web/live/stats_live_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,6 @@ defmodule AppWeb.StatsLiveTest do
[first_element | _] = Floki.find(result, "td[data-test-id=person_id]")

# assert first_element |> Floki.text() =~ "1"
first_element |> Floki.text() |> dbg()
first_element |> Floki.text()
end
end

0 comments on commit 6aae78a

Please sign in to comment.