Skip to content

Conversation

@ellnix
Copy link
Contributor

@ellnix ellnix commented Mar 13, 2025

  • These tests were particularly slow, this is about a 50% reduction in time to complete (as reported by rspec).
  • In addition refactored to clean up deprecation warnings from test output

@codecov
Copy link

codecov bot commented Mar 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.54%. Comparing base (5450df2) to head (8b4e067).
Report is 22 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #406   +/-   ##
=======================================
  Coverage   89.54%   89.54%           
=======================================
  Files          13       13           
  Lines         775      775           
=======================================
  Hits          694      694           
  Misses         81       81           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ellnix
Copy link
Contributor Author

ellnix commented Mar 13, 2025

+cc @wesharper if you would like to review.

@ellnix ellnix force-pushed the refactor_multi_search branch from 1e74e30 to 8b4e067 Compare March 14, 2025 19:22
@wesharper
Copy link

Looks good! I like the insert_all pattern. We've had issues in our own app with individual create! calls slowing down tests for us.

@curquiza curquiza added the maintenance Anything related to maintenance (CI, tests, refactoring...) label Mar 19, 2025
Product.create! name: 'palm pixi plus', href: 'ebay', tags: ['terrible']
Product.create! name: 'lg vortex', href: 'ebay', tags: ['decent']
Product.create! name: 'palmpre', href: 'ebay', tags: ['discontinued', 'worst phone ever']
Product.insert_all([
Copy link
Member

Choose a reason for hiding this comment

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

Inserts multiple records into the database in a single SQL INSERT statement. It does not instantiate any models nor does it trigger Active Record callbacks or validations. Though passed values go through Active Record’s type casting and serialization.

Interesting that you create the records then you reindex the model, very clever!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!

It's a method used very often in seed files, you can imagine that with a lot more records it would be a non-trivial amount of memory and computation to instantiate a ActiveRecord object for all of them.

I'm not really very happy with the solution here, I think it's a little bit undercooked, but I'm saving any refactoring for the inevitable PR where I probably make every test file into an rspec behavior so that I can apply it to every storage backend (AR, Sequel, Mongo).

@ellnix
Copy link
Contributor Author

ellnix commented Mar 24, 2025

bors merge

@meili-bors meili-bors bot merged commit 3f46ded into meilisearch:main Mar 24, 2025
12 checks passed
@ellnix ellnix added the skip-changelog The PR will not appear in the release changelogs label Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Anything related to maintenance (CI, tests, refactoring...) skip-changelog The PR will not appear in the release changelogs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants