Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: implement remove_item_from_list/3 function #422

Closed
4 tasks done
Tracked by #165
nelsonic opened this issue Sep 13, 2023 · 4 comments
Closed
4 tasks done
Tracked by #165

Feat: implement remove_item_from_list/3 function #422

nelsonic opened this issue Sep 13, 2023 · 4 comments
Assignees
Labels
elixir Pull requests that update Elixir code enhancement New feature or enhancement of existing functionality priority-1 Highest priority issue. This is costing us money every minute that passes. T25m Time Estimate 25 Minutes technical A technical issue that requires understanding of the code, infrastructure or dependencies

Comments

@nelsonic
Copy link
Member

nelsonic commented Sep 13, 2023

As outlined in #420 we already have a simple way to add an item to a list:

mvp/lib/app/list.ex

Lines 149 to 154 in b8aee0e

def add_item_to_list(item_cid, list_cid, person_id) do
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

need a way of removing an item from the list so that we can easily move the item to a different list.

Todo

  • Write tests for remove_item_from_list/3 🧪
  • Implement remove_item_from_list/3 function to pass tests 🧑‍💻
  • Document it with examples in /book 📘
  • Ship. :shipit:
@nelsonic nelsonic added enhancement New feature or enhancement of existing functionality T25m Time Estimate 25 Minutes technical A technical issue that requires understanding of the code, infrastructure or dependencies priority-1 Highest priority issue. This is costing us money every minute that passes. elixir Pull requests that update Elixir code labels Sep 13, 2023
@nelsonic nelsonic self-assigned this Sep 13, 2023
@nelsonic
Copy link
Member Author

Quick side-quest: dwyl/useful#55

@nelsonic
Copy link
Member Author

https://hexdocs.pm/useful/1.13.1/Useful.html#remove_item_from_list/2 📦 :shipit:

@nelsonic
Copy link
Member Author

Easy:

mvp/lib/app/list.ex

Lines 188 to 198 in f212cd5

def remove_item_from_list(item_cid, list_cid, person_id) do
list = get_list_by_cid!(list_cid)
# get existing list.seq
seq =
get_list_seq(list)
# remove the item_cid from the list.seq:
|> Useful.remove_item_from_list(item_cid)
|> Enum.join(",")
update_list(list, %{seq: seq, person_id: person_id})
end

Documented in: mvp/19-add-item-to-list.md#remove-item-from-list

Published at: https://dwyl.github.io/book/mvp/19-add-item-to-list.html

@nelsonic
Copy link
Member Author

Included in #165 :shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
elixir Pull requests that update Elixir code enhancement New feature or enhancement of existing functionality priority-1 Highest priority issue. This is costing us money every minute that passes. T25m Time Estimate 25 Minutes technical A technical issue that requires understanding of the code, infrastructure or dependencies
Projects
Status: Done
Status: Done
Development

No branches or pull requests

1 participant