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

Create DebtFilter module for Bet #56

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ghost
Copy link

@ghost ghost commented Mar 21, 2017

Pivotal: https://www.pivotaltracker.com/story/show/141907091
-DebtFilter addresses the problem, where some of the created Debts for a
particular Bet would cross-reference each other (PersonA -$50-> PersonB
&& PersonB -$20-> PersonA) or accumulate as separate entries (PerosnA
-$50-> PersonB && PersonA -$20-> PersonB) by filtering them before
saving.
-Added DebtFilter to Bet model. Debts are now filtered before getting
saved.

Copy link
Member

@luukveenis luukveenis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's room to simplify the DebtFilter module a lot. Instead of pointing out lots of little changes, I'd encourage you to try refactoring it.

reverse_negatives(merge_debts(reverse_duplicates(debts)))
end

def unique_participants(debts)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole method can be written in a much simpler way.
Hint: Think about the fact that you're creating an array called uniques and ensuring uniqueness of the things you're adding to it.

@@ -0,0 +1,55 @@
module DebtFilter
Copy link
Member

@luukveenis luukveenis Mar 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This module has one public method, but 5 private methods that handle combining debts between the same people. These methods also iterate over the same array many times, maybe see if you can simplify this.

@jacquesporveau
Copy link
Member

This branch is out of date with master. Please update.

-DebtFilter addresses the problem, where some of the created Debts for a
particular Bet would cross-reference each other (PersonA -$50-> PersonB
&& PersonB -$20-> PersonA) or accumulate as separate entries (PerosnA
-$50-> PersonB && PersonA -$20-> PersonB) by filtering them before
saving.
-Added DebtFilter to Bet model. Debts are now filtered before getting
saved.
@ghost ghost force-pushed the removing_duplicates_from_resolved_bet branch from 371eb98 to ec4c39c Compare April 5, 2017 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants