bigardone / phoenix-trello

Trello tribute done in Elixir, Phoenix Framework, React and Redux.
https://phoenix-trello.herokuapp.com
MIT License
2.5k stars 409 forks source link

Refactor card controller query to make less SQL queries #15

Closed bjfish closed 8 years ago

bjfish commented 8 years ago

I was modifying this query to help me learn Ecto. I changed it so it now only does 2 SQL queries for this action. Feel free to use this change if you would like.

bigardone commented 8 years ago

Hi! Thanks for the PR! I'm also learning Ecto so any suggestion is really appreciated :)
Do you think we can move that query to the Card module so we can cleanup the controller and use something like:

card = Card |> Card.get_by_user_and_board(card_id, user_id, board_id)

I 'd rather prefer having such query functionality in the Card so it can be reused elsewhere...

bjfish commented 8 years ago

@bigardone Yes, I moved the query and updated the controller.

bigardone commented 8 years ago

Awesome! Thank you very much, merging!