Skip to content
This repository has been archived by the owner on Oct 17, 2020. It is now read-only.

Added Search struct to search URLs for a user #551

Closed
wants to merge 5 commits into from

Conversation

dawntomm
Copy link
Contributor

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.

@dawntomm dawntomm self-assigned this Mar 12, 2020
@dawntomm dawntomm added this to In progress in Short 1.0 via automation Mar 12, 2020
@dawntomm dawntomm added this to the 03/07 - 03/13 milestone Mar 12, 2020
@dawntomm dawntomm linked an issue Mar 12, 2020 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Mar 12, 2020

Codecov Report

Merging #551 into master will increase coverage by 0.13%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            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
Flag Coverage Δ
#golang 78.94% <66.66%> (-0.17%) ⬇️
#typescript 3.85% <ø> (ø) ⬆️
Impacted Files Coverage Δ
backend/app/usecase/search/search.go 66.66% <66.66%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dd8d778...bfcb5af. Read the comment docs.

Copy link
Contributor

@alldroll alldroll left a 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)
Copy link
Contributor

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?

Copy link
Member

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)
Copy link
Contributor

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.

Short 1.0 automation moved this from In progress to In Review Mar 12, 2020
@magicoder10
Copy link
Member

#260

@magicoder10
Copy link
Member

Please support pagination: #260 (comment)

@magicoder10
Copy link
Member

Hi @dawntomm, the code coverage is dropping.

Copy link
Member

@magicoder10 magicoder10 left a 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
Copy link
Member

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.

@magicoder10
Copy link
Member

Closing this PR because the APIs will be redesigned to support pagination.

Short 1.0 automation moved this from In Review to Done Mar 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
Short 1.0
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants