liquidvotingio / liquidvotingio/api
Make better use of Multi.run
Nobody has claimed this yet.
- Dominant language
- Elixir
- Stars
- 17
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Description
Use `Multi.run` to compose sequential db operations.
For example, we perform 3 different `get_by` db queries in `get_delegation!/5`, in `lib/liquid_voting/delegations.ex`, before a final `get_by` to find the delegation.
`Multi.run` could be used here, and any for other similarly sequential db operations. It has many advantages, one of which being that it ["saves multiple round trips to the database"](https://elixirschool.com/blog/ecto-multi/).
For an example of `Multi.run`, see `create_delegation/1` (the clause that uses emails), also in `lib/liquid_voting/delegations.ex`.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in lib/liquid_voting/delegations.ex by reading get_delegation!/5 and the email-based create_delegation/1 clause, which is given as the Multi.run example. Look for other similarly sequential database operations, then verify the existing test suite passes and that the delegation queries still produce the expected results.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- elixir
- Domain
- backend, database
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100