2 ms·
> Map<CustomerId, Set<PageId>> will do You can do a little better than that. Each item in your map has exactly 3 states: - We’ve seen this customer visit one
by josephg 3y ago
> Map<CustomerId, Set<PageId>> will do
You can do a little better than that. Each item in your map has exactly 3 states:
- We’ve seen this customer visit one unique page with (xx) url on the first day
- We’ve seen this customer visit two unique pages - but only on the first day.
- We’ve seen the customer visit one unique page (xx) and they’ve visited on both days.
In the second state you don’t actually care what the URLs are. And I think the logic for the 3rd state is identical to the logic for the 1st state - since you only add them as a “loyal customer” by visiting them again on the second day. So I think you can get away with using an Option<Url> to store the state instead of a Set or a list. (Though I’d probably use a custom parametric enum for clarity).
It’s a great problem to model using a state machine.
- gpderetta 3y agoIt is mentioned later that you only need to list at most one URL .