LG-8510: Don't display the same post office multiple times#7774
LG-8510: Don't display the same post office multiple times#7774eileen-nava merged 2 commits intomainfrom
Conversation
| def dedupe_facilities(facilities) | ||
| facilities.uniq do |facility| | ||
| [facility.address, facility.city, facility.state, facility.zip_code_5] | ||
| end |
There was a problem hiding this comment.
would it be worth throwing on a sort here too just in case?
| end | |
| end.sort_by { |facility| facility.distance } |
There was a problem hiding this comment.
Hm, I don’t think that change is necessary. I have yet to see any instances of post offices being returned out of order, and I wouldn’t expect the dedupe_facilities method to throw off order. If you disagree, please let me know. 🙏🏻
There was a problem hiding this comment.
I haven't checked the API but figured maybe it would be a good check to have just in case. Fine to ship without! 👍
There was a problem hiding this comment.
I don't see the distance-based ordering represented as a guarantee in the API documentation, so I would normally be inclined to hedge my bets by ordering it. That said, I don't think the current ordering is truly at risk of changing any time soon. Maybe we could get updated API docs that state the ordering as a guarantee.
🎫 Ticket
Deduplicate Post Offices with the same street address for display
🛠 Summary of changes
Previously, if the USPS API returned the same post office multiple times, our search feature would display duplicate post offices. This bug was obvious when the user searched for
3775 INDUSTRIAL BLVD WEST SACRAMENTO CA 95799.Now, our search feature will only return each post office one time.
📜 Testing Plan
Provide a checklist of steps to confirm the changes.
3775 INDUSTRIAL BLVD WEST SACRAMENTO CA 95799👀 Screenshots
If relevant, include a screenshot or screen capture of the changes.
Before:
SacramentoDuplicates.mov
After:
SacramentoNoDuplicates.mov