Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keys changes v2 #340

Merged
merged 3 commits into from
Jul 11, 2022
Merged

Keys changes v2 #340

merged 3 commits into from
Jul 11, 2022

Conversation

brunoocasali
Copy link
Member

@brunoocasali brunoocasali commented Jul 7, 2022

  • Add options to client.keys(limit:, offset:) limit and offset to allow paginate the results.
  • Use a better name in the arguments list in the create_key, update_key and delete_key: uid_or_key instead of just key_uid because now is possible to use both of them.

Base automatically changed from fix-missing-tests to bump-meilisearch-v0.28.0 July 7, 2022 19:14
Copy link
Member

@curquiza curquiza left a comment

Choose a reason for hiding this comment

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

👨‍🎤

client.create_key(add_docs_key_options)

expect(client.keys(limit: 0, offset: 20)['results']).to be_empty
expect(client.keys(limit: 5, offset: 199)['results']).to be_empty
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I get the point of this test. Why do you set a limit of 5 but expect it to be empty?

Copy link
Member Author

Choose a reason for hiding this comment

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

The answer is more complex than what I'm going to say to you, but what I can say is:

If we set a "random" limit/offset combination that will probably be out of bounds and make a request Meilisearch should return an empty array as the result.

I know it sounds counter-intuitive, but in the future our idea is to remove all of these tests and replace them by mocks like this:

    it 'sends limit/offset in the request' do
       expect(a_request(:get, "www.meilisearch.com").with(query: {"limit" => 5, "offset" => 10})).
  to have_been_made
  
       client.keys(limit: 5, offset: 10)
    end

Because if you agree with me, it will be enough to guarantee the contract between the API (Meili), and the caller (SDK).

@brunoocasali brunoocasali merged commit cb38a23 into bump-meilisearch-v0.28.0 Jul 11, 2022
@brunoocasali brunoocasali deleted the keys-changes-v2 branch July 11, 2022 12:01
meili-bors bot added a commit that referenced this pull request Jul 11, 2022
343: Update version for the next release (v0.19.0) r=brunoocasali a=brunoocasali

This version makes this package compatible with Meilisearch v0.28.0 🎉
Check out the changelog of [Meilisearch v0.28.0](https://github.com/meilisearch/meilisearch/releases/tag/v0.28.0) for more information on the changes.

## 💥  Breaking Changes

breaking changes:

- `MeiliSearch::Client#keys` now returns a hash with: (#340) `@brunoocasali`
  - `results` array
  - `limit` integer
  - `offset` integer
  - `total` integer
- `MeiliSearch::Index#indexes`, `MeiliSearch::Client#raw_indexes` now returns a hash with: (#342) `@brunoocasali`
  - `results` array
  - `limit` integer
  - `offset` integer
  - `total` integer
- `MeiliSearch::Client#create_dump` now responds with a `Task` object. (#335) `@brunoocasali`
- `MeiliSearch::Client#get_dump_status` was removed. Use the `MeiliSearch::Client#tasks` or `MeiliSearch::Client#task` instead. (#335) `@brunoocasali`
- `MeiliSearch::Index#search`: (#331) `@curquiza`
  - Renamed `nbHits` response parameter to `estimatedTotalHits`.
  - Deleted `exhaustiveNbHits` response parameter.
  - Deleted `exhaustiveFacetsCount` response parameter.
  - `_matchesInfo` response parameter is renamed `_matchesPosition`.
  - `facetsDistribution` response parameter is renamed `facetDistribution`.
  - `facetsDistribution` request parameter is renamed `facets`.
  - `matches` request parameter is renamed `showMatchesPosition`.
- `MeiliSearch::Index#documents` now returns an hash with: (#342) `@brunoocasali`
  - `results` array
  - `limit` integer
  - `offset` integer
  - `total` integer
- `MeiliSearch::Index#tasks` now returns a hash with: (#336), (#341) `@brunoocasali`
  - `results` array
  - `limit` integer
  - `from` integer
  - `next` integer
- `add_documents`, `create_dump`, `update_settings` and other methods that "creates" a new task, now responds with a `taskUid` instead of `uid` (#336), (#341) `@brunoocasali`
- `MeiliSearch::Client#generate_tenant_token(uid, search_rules, api_key: api_key, expires_at: expires_at)` now requires a `api key uid` to generate tenant tokens. (#340) `@brunoocasali`

## 🐛 Enhancements

- `MeiliSearch::Client#indexes`, `MeiliSearch::Client#raw_indexes` now accepts an hash with pagination `limit`, `offset`.
- `MeiliSearch::Client#documents`, now accepts an hash with pagination `limit`, `offset`. (#342) `@brunoocasali`
- `MeiliSearch::Client#document`, now accepts a named param called `fields` which takes an array of strings to remap the response. (#342) `@brunoocasali`
- `MeiliSearch::Client#tasks`, now accepts these filtering parameters: `type`, `status` and `index_uid`. Usage example: `tasks(status: ['processing'], type: ['documentAdditionOrUpdate'])`. (#336), (#341) `@brunoocasali`
- `MeiliSearch::Client#create_key`, `MeiliSearch::Client#delete_key`, `MeiliSearch::Client#update_key` accepts both `api key` or `api key uid`. (#340) `@brunoocasali`
- `MeiliSearch::Client#create_key` can optionally specify a `uid:` to generate deterministic API keys. (#340) `@brunoocasali`
- `MeiliSearch::Client#update_key` only accepts `description` and `name`, other keys will be removed silently. (#340) `@brunoocasali`

Thanks again to `@brunoocasali,` `@curquiza!` 🎉


Co-authored-by: Bruno Casali <brunoocasali@gmail.com>
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.

None yet

3 participants