Skip to content

Commit

Permalink
Return more matches
Browse files Browse the repository at this point in the history
  • Loading branch information
ahobsonsayers committed Apr 19, 2024
1 parent d401cf0 commit afe3e89
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions goodreads/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,14 @@ func (c *Client) SearchBooks(ctx context.Context, bookTitle string, bookAuthor *
return nil, err
}

bookIds = utils.Intersection(bookIds, authorBookIds)
// Get common book ids. If there are no common book
// ids, just use the book ids form the title search.
// Some result are better than none!
commonBookIds := utils.Intersection(bookIds, authorBookIds)
if len(commonBookIds) != 0 {
bookIds = commonBookIds
}

}

// Get book details using their ids
Expand Down Expand Up @@ -210,7 +217,8 @@ func (c *Client) searchBookIdsByAuthor(ctx context.Context, author string) ([]st
var bookIdsMutex sync.Mutex
var errsMutex sync.Mutex

for pageNumber := 1; pageNumber <= 5; pageNumber++ {
// Get 10 pages of author books. This should be enough
for pageNumber := 1; pageNumber <= 10; pageNumber++ {
wg.Add(1)

go func(page int) {
Expand Down

0 comments on commit afe3e89

Please sign in to comment.