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

Implement new await synchronous interface #498

Merged
merged 10 commits into from
Feb 27, 2024

Conversation

ellnix
Copy link
Collaborator

@ellnix ellnix commented Oct 9, 2023

Pull Request

Related issue

Fixes #288

While refactoring, inadvertently fixes:

PR checklist

Please check if your PR fulfills the following requirements:

  • Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • Have you read the contributing guidelines?
  • Have you made sure that the title is accurate and descriptive of the changes?

Changes Checklist

  • Add soft deprecation messages
  • Remove bang methods from specs
  • Add Task "model"
  • Ensure all tests pass with edits where necessary
  • Add tests to make sure that all bang methods actually provide deprecation warnings
  • Return Task model on all methods that return tasks
    • Return Task model from all settings setters and getters
  • Update the documentation with new syntax (if applicable)

@ellnix ellnix changed the title New await sync interface Implement new await synchronous interface Oct 9, 2023
@codecov
Copy link

codecov bot commented Oct 9, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.85%. Comparing base (dcc99be) to head (75017dc).
Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #498      +/-   ##
==========================================
+ Coverage   99.81%   99.85%   +0.03%     
==========================================
  Files           9       10       +1     
  Lines         542      671     +129     
==========================================
+ Hits          541      670     +129     
  Misses          1        1              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ellnix ellnix force-pushed the new-await-sync-interface branch 3 times, most recently from ff3856a to 5fbcab1 Compare October 12, 2023 12:00
@ellnix
Copy link
Collaborator Author

ellnix commented Oct 12, 2023

@brunoocasali this is pretty much complete, please feel free to review when you have (a lot of) time. 👨‍💻 🤯

@ellnix ellnix marked this pull request as ready for review October 12, 2023 15:46
@ellnix
Copy link
Collaborator Author

ellnix commented Oct 16, 2023

Rebased and force pushed.

Copy link
Member

@brunoocasali brunoocasali left a comment

Choose a reason for hiding this comment

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

Thanks a lot for your hard work here @ellnix amazing!

I am asking for some changes but it is nothing to be worried about!

lib/meilisearch/client.rb Show resolved Hide resolved
lib/meilisearch/index.rb Outdated Show resolved Hide resolved
lib/meilisearch/models/task.rb Outdated Show resolved Hide resolved
spec/meilisearch/client/dumps_spec.rb Show resolved Hide resolved
spec/meilisearch/models/task_spec.rb Show resolved Hide resolved
spec/meilisearch/models/task_spec.rb Outdated Show resolved Hide resolved
# frozen_string_literal: true

describe MeiliSearch::Model::Task do
let(:new_index_uid) { random_uid }
Copy link
Member

Choose a reason for hiding this comment

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

Can you apply the xUnit structure here? And the https://betterspecs.org guides about the naming of the contexts using with/when?!a

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The contexts have been renamed.

About the xUnit structure, I am assuming you specifically mean the setup, exercise, verify, and teardown steps?

  • setup is done in rspec lets which by design are shared so do not directly appear in a test's body, should I clarify them somehow or have a line in each test explicitly create the correct context for clarity?
  • exercise and verify are often in the same line of code for brevity, should I expand them?
  • teardown is also handled by rspec lets, and as far as I know there is no context leaking between specs

Copy link
Member

@brunoocasali brunoocasali left a comment

Choose a reason for hiding this comment

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

Amazing work @ellnix I think we could make some small modifications, but I was impressed, very good work!

@ellnix
Copy link
Collaborator Author

ellnix commented Nov 29, 2023

@brunoocasali sorry for taking so long to get back to this. I addressed your feedback and rebased it to main (for the changes since you last reviewed it, start at commit b141ed4).

P. S.: The tests pass but codecov is broken again.

@brunoocasali
Copy link
Member

let's see if the code coverage will still be broken now!

Also, can you squash the commits @ellnix ?

@ellnix
Copy link
Collaborator Author

ellnix commented Dec 11, 2023

Also, can you squash the commits @ellnix ?

Squash them into a single commit or just fewer commits? How many commits would you consider ideal? The history might be a little bit hard to follow if only a few commits had +1800 -1200 changes.

lib/meilisearch/utils.rb Show resolved Hide resolved
spec/meilisearch/models/task_spec.rb Show resolved Hide resolved
lib/meilisearch/index.rb Outdated Show resolved Hide resolved
lib/meilisearch/models/task.rb Outdated Show resolved Hide resolved
spec/meilisearch/models/task_spec.rb Outdated Show resolved Hide resolved
# frozen_string_literal: true

describe MeiliSearch::Model::Task do
let(:new_index_uid) { random_uid }
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The contexts have been renamed.

About the xUnit structure, I am assuming you specifically mean the setup, exercise, verify, and teardown steps?

  • setup is done in rspec lets which by design are shared so do not directly appear in a test's body, should I clarify them somehow or have a line in each test explicitly create the correct context for clarity?
  • exercise and verify are often in the same line of code for brevity, should I expand them?
  • teardown is also handled by rspec lets, and as far as I know there is no context leaking between specs

@brunoocasali
Copy link
Member

Squash them into a single commit or just fewer commits? How many commits would you consider ideal? The history might be a little bit hard to follow if only a few commits had +1800 -1200 changes.

A few commits would be great. I don't have a number for that, it is more a feeling than anything. If you squash them based on the group like, you did a lot of the same but in multiple files, so in my mind you would have a single commit of that "theme".

@ellnix
Copy link
Collaborator Author

ellnix commented Jan 10, 2024

@brunoocasali should be ready for merge, unless you want me to squash it down further.

Comment on lines +67 to +69
allow(subject).to receive(:refresh)
subject.enqueued?
expect(subject).not_to have_received(:refresh)
Copy link
Member

Choose a reason for hiding this comment

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

When I mention the xUnit I mean this:

Suggested change
allow(subject).to receive(:refresh)
subject.enqueued?
expect(subject).not_to have_received(:refresh)
allow(subject).to receive(:refresh)
subject.enqueued?
expect(subject).not_to have_received(:refresh)

brunoocasali
brunoocasali previously approved these changes Feb 14, 2024
Copy link
Member

@brunoocasali brunoocasali left a comment

Choose a reason for hiding this comment

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

Looks good to me, let get this merged @ellnix

Thanks a lot for all the hard work in this repo @ellnix ❤️

@brunoocasali brunoocasali added the enhancement New feature or request label Feb 14, 2024
@ellnix
Copy link
Collaborator Author

ellnix commented Feb 16, 2024

I'm not sure this will work, but addressing the conflict with a commit might dismiss the approval review.

bors merge

Copy link
Contributor

meili-bors bot commented Feb 16, 2024

Merge conflict.

@ellnix
Copy link
Collaborator Author

ellnix commented Feb 16, 2024

Give me a second with this, apparently the git pull on my fork didn't go through properly and now everything is messed up.

Refactor all doc methods & specs with Model::Task
Update global settings methods to use Model::Task
Update ranking_rules methods to use Model::Task
Update distinct attribute methods with Model::Task
Update searchable attr methods to use Model::Task
Update displayed attrs methods with Model::Task
Update synonoms methods to use Model::Task
Update stop words methods to use Model::Task
Update filterable attrs methods to use Model::Task
Update sortable attrs methods to use Model::Task
Update typo tolerance methods with Model::Task
Update faceting settings methods with Model::Task
Update user dict methods to use Model::Task
Update (non) separator methods to use Model::Task
Update Index#update and #delete to use Model::Task
Replace calls to wait_for_task in specs which I had missed somehow
Remove now-redundant TaskHelpers
Update some Client methods&specs with Model::Task
Add Model::Task to Client#dump and other specs
@ellnix
Copy link
Collaborator Author

ellnix commented Feb 16, 2024

Well I fixed the git history and force pushed. Sorry about the issues but I don't think there was a way for me to resolve the main conflicts without automatically dismissing the approval review (even when I tried a merge rather than a rebase).

I looked it up, it seems to be a setting (isaacs/github#783 (comment)) but it does not look like it would be a good idea, since it would allow someone with approval to push arbitrary code and then choose to merge.

Copy link
Member

@brunoocasali brunoocasali left a comment

Choose a reason for hiding this comment

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

LGTM!

@ellnix
Copy link
Collaborator Author

ellnix commented Feb 27, 2024

bors merge

Copy link
Contributor

meili-bors bot commented Feb 27, 2024

Build succeeded:

@meili-bors meili-bors bot merged commit 65a34c9 into meilisearch:main Feb 27, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants