-
Notifications
You must be signed in to change notification settings - Fork 146
Added Search struct to search URLs for a user #551
Conversation
Codecov Report
@@ Coverage Diff @@
## master #551 +/- ##
=========================================
+ Coverage 49.37% 49.5% +0.13%
=========================================
Files 81 82 +1
Lines 1511 1523 +12
Branches 97 97
=========================================
+ Hits 746 754 +8
- Misses 731 733 +2
- Partials 34 36 +2
Continue to review full report at Codecov.
|
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.
Thank you, Tom!
Please address my review comments
|
||
// SearchForURLs fetches all URLs for a given user | ||
func (s Search) SearchForURLs(user entity.User) ([]entity.URL, error) { | ||
aliases, err := s.userURLRepo.FindAliasesByUser(user) |
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.
I do concern about the possible high load problems. I don't know we have restrictions for a number of links created by a user, but how to be if a user has 10k links?
I suggest implementing paginator
in order to make this potential problem less impact.
What are your thoughts about it?
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.
Let's rename this to search
and internal search for URL.
|
||
for _, testCase := range testCases { | ||
t.Run(testCase.name, func(t *testing.T) { | ||
searchAPI := NewSearch(&urlRepo, &userUrlRepo) |
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.
let's initialize &urlRepo, &userUrlRepo
inside Run
.
Please support pagination: #260 (comment) |
Hi @dawntomm, the code coverage is dropping. |
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.
Please check this as example API: https://github.com/short-d/short/tree/search
CreatedBy: &user_1, | ||
} | ||
urlMap := make(map[string]entity.URL) | ||
urlMap["baidu"] = url_1 |
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.
urlMap["baidu"] = url_1 | |
urlMap["baidu"] = url_1 |
Let's use well known examples across the world.
|
||
// SearchForURLs fetches all URLs for a given user | ||
func (s Search) SearchForURLs(user entity.User) ([]entity.URL, error) { | ||
aliases, err := s.userURLRepo.FindAliasesByUser(user) |
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.
Let's rename this to search
and internal search for URL.
Closing this PR because the APIs will be redesigned to support pagination. |
New Behavior
Description
Added Search struct to search URLs for a user.
User should be able to search the public and the private short links they created. In order to support that, we add RESTful API to search for all urls created by a given user. The second step is to add Search struct, which provides function to search urls for a user.