Open tmlee opened 3 years ago
The loop can be removed, but the justification was 'just in case'. Although uuids itself are unique, but since only the first 7 characters are extracted, i was not sure what are the chances of a repeated 7-character lookup code (although the probability do be kinda low, now thinking about it). I'll remove it.
I'll remove it and change link.model
just to Link
.
For 3 and 4, I am aware that this project has not achieve all the requirements stated in the email. I have a rough idea, but I'll solidify and implement it ASAP.
counter
into Link
model.Visitor
model with link_id
as foreign key. Each Link
has many Visitor
.Visitor
entry.original_url
, shortened_url
and counter
.ip
is/are shown.
https://github.com/DanielChang98/link-shortener/blob/main/app/services/shortener.rb#L18 Knowing how hash function works, if you want to proceed with your approach of generating new codes, is a loop check necessary?
Why pass in a Link object here when it seems like it won't be anything else? https://github.com/DanielChang98/link-shortener/blob/main/app/services/shortener.rb#L6
If we want to add a new feature to track the number of clicks and IP source for when a shortened URL is visited by a suer, how would you implement that? Display the results publicly.
After implementing the above, how can we improve the performance of a link visit while also counting the number of visits?