-
Notifications
You must be signed in to change notification settings - Fork 70
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
New match brand logic. #127
Conversation
@Fivell, could you review please? |
@pavelgyravel thanks will do soon |
@pavelgyravel what do you think about different approach, just an idea, currently when we are adding branch rules in the beginning of the brands hash detecting mechanism find first key value pair and return brand
what if we will try to insert new branch in the beginning so manually added rules will have better priority instead of
we can try something
after it brands keys will have koritmilli on the first place tested with ruby2.7
|
end | ||
|
||
if matched_brands.present? | ||
return matched_brands.sort{|a, b| a[:matched_prefix_length] <=> b[:matched_prefix_length]}.last[:brand] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pavelgyravel i think can be implemented in more easy way , commented PR with separate message take a look please
@Fivell, thank you for your time! Your proposal should work in my case. But in general, i think, algorithm I purposed, is more accurate. Frequently local brands has same prefix, but wider as brands like maestro, but thay are not kobrands or part of that brand. So I think that brand recognition wil better work when its based on more accurate intersection of prefix |
@pavelgyravel , ok i've got your point , lets try it ! |
Вітаю!
Problem:
After adding new brand which intersects with existed brand prefix but with more accurate prefix, detector still return old brand value.
Example:
We have brand maestro with prefix 505. We add new brand kortimilli with more accurate prefix 505827028.
CreditCardValidations::Detector.add_brand(:kortimilli, length: 15, prefixes: '505827028')
But detector still return maestro instead kortimilli
CreditCardValidations::Detector.new('505827028341713').brand # => :maestro
Solution:
Instead of returning first matched by prefix brand, we get all matched and return one with more accurate prefix length.