Skip to content

Conversation

@SaraVieira
Copy link
Contributor

@SaraVieira SaraVieira commented May 22, 2019

Finishing of #1954

cc @Haroenv

Haroenv and others added 3 commits May 22, 2019 11:02
Note that I blind coded this, so definitely check out in the preview if it works.

reference: https://www.algolia.com/doc/api-reference/api-methods/get-objects/?language=javascript

I also changed the require out for the way smaller `algoliasearch/lite`
@SaraVieira SaraVieira changed the title Pr/1954 Make more efficient query May 22, 2019
index.search({ query: dependency, hitsPerPage: 1 }, (err, { hits }) => {
const versions = Object.keys(hits[0].versions).sort((a, b) => {
index.getObject(dependency, ['versions']).then(({ versions: hits }) => {
const versions = Object.keys(hits).sort((a, b) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd keep calling this versions though, since hits is a list of packages usually

Copy link
Contributor

Choose a reason for hiding this comment

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

oh I see the problem now, the variable was declared twice

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The names clash, that's why I renamed it.

Im gonna rename to results, is that a better name?

Copy link
Contributor

Choose a reason for hiding this comment

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

index.getObject(dependency, ['versions']).then(result =>
  const versions = Object.keys(result.versions).sort((a, b) => {

This could work too

@SaraVieira SaraVieira merged commit 4a2cebb into master May 22, 2019
@SaraVieira SaraVieira deleted the pr/1954 branch May 22, 2019 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants