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

Feature: Implementation of createMany lifecycle hook #972

Merged
merged 43 commits into from
Jan 6, 2025

Conversation

Ra0R
Copy link
Contributor

@Ra0R Ra0R commented Nov 4, 2024

Pull Request

  • Implemented createMany-Hook that is available sinceStrapi v4.9.0, the createMany()-Lifecycle hook properly returns a count and a set of ids after creation.
  • Test of the implemented function also extended mock to properly test behaviour
  • Bumped peerDependencies to "peerDependencies": { "@strapi/strapi": "^4.9.0" }

Related issue

Fixes #965
Probably fixes #399 (I am not sure how tasks are updated upon restart)

What does this PR do?

  • ...

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?
    However, I could not lint since there would be changes in 67 to remove carriage-returns( error Delete prettier/prettier )

  • Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!

@Ra0R Ra0R changed the title Feat/create many lifecycle hook Feature: Implementation of createMany lifecycle hook Nov 4, 2024
@Ra0R Ra0R marked this pull request as draft November 4, 2024 15:01
@Ra0R
Copy link
Contributor Author

Ra0R commented Nov 4, 2024

@brunoocasali Looking forward to your review.

@Ra0R Ra0R marked this pull request as ready for review November 10, 2024 14:17
@dosomder
Copy link

@brunoocasali Any news on this? This would be an important change also for the company I am working at

@brunoocasali
Copy link
Member

Hi folks! I just merged the support for strapi v5 #964, which made this PR outdated. Can you fix those conflicts?

@brunoocasali brunoocasali self-requested a review November 25, 2024 19:32
@brunoocasali brunoocasali added the enhancement New feature or request label Nov 25, 2024
@Ra0R
Copy link
Contributor Author

Ra0R commented Nov 26, 2024

Hi folks! I just merged the support for strapi v5 #964, which made this PR outdated. Can you fix those conflicts?

Hey Bruno, We can address these changes. Regardless, I think these changes should've been merged and released in a minor version of the plugin. Since some people might not be able to upgrade to Strapi v5 and (correct me) the newer plugin version will not be compatible with Strapi v4?

@brunoocasali
Copy link
Member

You're right :/

Even if the plugin is compatible, users could have other plugins blocking their upgrade. So, if we want to provide the feature to both cases, we would need to provide two different releases.

If you're willing to do it, we can do that!

I would ask you to open another PR pointing to the HEAD before the last merge v0.12.0. Then, I can release it as v0.12.1.

const ids = result.ids

const entries = []
const BATCH_SIZE = 500
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 transform this into a customizable param that people could choose from in the plugin initializer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a hard limit given by strapis sql engine when compiling a query (or the database im not sure).

server/src/services/meilisearch/connector.js Outdated Show resolved Hide resolved
@brunoocasali
Copy link
Member

bors merge

brunoocasali
brunoocasali previously approved these changes Dec 11, 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.

LGTM! 🎉

Thanks a lot for your PR! If you want to release it for v4, you can create a PR like I mentioned earlier!

curquiza
curquiza previously approved these changes Dec 11, 2024
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.

bors merge

@curquiza
Copy link
Member

@Ra0R, sorry, can you rebase? Looks like we cannot merge with our tool (bug) and the branch is out dated, but I don't know why I cannot update it 😢

So, can you rebase (or pull main) so that we can merge manually?

meili-bot and others added 3 commits December 11, 2024 14:58
Bumps the production group with 5 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| @strapi/design-system | `2.0.0-rc.11` | `2.0.0-rc.14` |
| @strapi/icons | `2.0.0-rc.11` | `2.0.0-rc.14` |
| [meilisearch](https://github.com/meilisearch/meilisearch-js) | `0.42.0` | `0.45.0` |
| [@strapi/sdk-plugin](https://github.com/strapi/sdk-plugin) | `5.2.6` | `5.2.7` |
| [@strapi/strapi](https://github.com/strapi/strapi) | `5.0.1` | `5.4.1` |



Updates `@strapi/design-system` from 2.0.0-rc.11 to 2.0.0-rc.14

Updates `@strapi/icons` from 2.0.0-rc.11 to 2.0.0-rc.14

Updates `meilisearch` from 0.42.0 to 0.45.0
- [Release notes](https://github.com/meilisearch/meilisearch-js/releases)
- [Commits](meilisearch/meilisearch-js@v0.42.0...v0.45.0)

Updates `@strapi/sdk-plugin` from 5.2.6 to 5.2.7
- [Release notes](https://github.com/strapi/sdk-plugin/releases)
- [Changelog](https://github.com/strapi/sdk-plugin/blob/main/CHANGELOG.md)
- [Commits](strapi/sdk-plugin@v5.2.6...v5.2.7)

Updates `@strapi/strapi` from 5.0.1 to 5.4.1
- [Release notes](https://github.com/strapi/strapi/releases)
- [Commits](strapi/strapi@v5.0.1...v5.4.1)

---
updated-dependencies:
- dependency-name: "@strapi/design-system"
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: production
- dependency-name: "@strapi/icons"
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: production
- dependency-name: meilisearch
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: production
- dependency-name: "@strapi/sdk-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: production
- dependency-name: "@strapi/strapi"
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: production
...

Signed-off-by: dependabot[bot] <[email protected]>
@curquiza
Copy link
Member

curquiza commented Dec 31, 2024

@Ra0R this is weird, there are commits in your branch (related to strapi v5) that should not be here.
Can you try the rebase again? Or remove the commits manually?

thank you again for the PR

@Ra0R
Copy link
Contributor Author

Ra0R commented Dec 31, 2024

@curquiza I merged main into the feature branch.

@curquiza
Copy link
Member

curquiza commented Dec 31, 2024

@Ra0R can you rebase instead of pulling? I created a guide here to do it.
https://gist.github.com/curquiza/5f7ce615f85331f083cd467fc4e19398

Sorry for the inconvenience

Ra0R and others added 21 commits January 2, 2025 10:07
…ad of creating a single update task for every document
Bumps the production group with 5 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| @strapi/design-system | `2.0.0-rc.11` | `2.0.0-rc.14` |
| @strapi/icons | `2.0.0-rc.11` | `2.0.0-rc.14` |
| [meilisearch](https://github.com/meilisearch/meilisearch-js) | `0.42.0` | `0.45.0` |
| [@strapi/sdk-plugin](https://github.com/strapi/sdk-plugin) | `5.2.6` | `5.2.7` |
| [@strapi/strapi](https://github.com/strapi/strapi) | `5.0.1` | `5.4.1` |



Updates `@strapi/design-system` from 2.0.0-rc.11 to 2.0.0-rc.14

Updates `@strapi/icons` from 2.0.0-rc.11 to 2.0.0-rc.14

Updates `meilisearch` from 0.42.0 to 0.45.0
- [Release notes](https://github.com/meilisearch/meilisearch-js/releases)
- [Commits](meilisearch/meilisearch-js@v0.42.0...v0.45.0)

Updates `@strapi/sdk-plugin` from 5.2.6 to 5.2.7
- [Release notes](https://github.com/strapi/sdk-plugin/releases)
- [Changelog](https://github.com/strapi/sdk-plugin/blob/main/CHANGELOG.md)
- [Commits](strapi/sdk-plugin@v5.2.6...v5.2.7)

Updates `@strapi/strapi` from 5.0.1 to 5.4.1
- [Release notes](https://github.com/strapi/strapi/releases)
- [Commits](strapi/strapi@v5.0.1...v5.4.1)

---
updated-dependencies:
- dependency-name: "@strapi/design-system"
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: production
- dependency-name: "@strapi/icons"
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: production
- dependency-name: meilisearch
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: production
- dependency-name: "@strapi/sdk-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: production
- dependency-name: "@strapi/strapi"
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: production
...

Signed-off-by: dependabot[bot] <[email protected]>
Bumps the playground group in /playground with 26 updates:

| Package | From | To |
| --- | --- | --- |
| [@strapi/plugin-users-permissions](https://github.com/strapi/strapi) | `5.0.1` | `5.4.2` |
| [@strapi/strapi](https://github.com/strapi/strapi) | `5.0.1` | `5.4.2` |
| [meilisearch](https://github.com/meilisearch/meilisearch-js) | `0.36.0` | `0.45.0` |
| [@strapi/admin](https://github.com/strapi/strapi) | `5.0.1` | `5.4.2` |
| [@strapi/cloud-cli](https://github.com/strapi/strapi) | `5.0.1` | `5.4.2` |
| [@strapi/content-manager](https://github.com/strapi/strapi) | `5.0.1` | `5.4.2` |
| [@strapi/content-releases](https://github.com/strapi/strapi) | `5.0.1` | `5.4.2` |
| [@strapi/content-type-builder](https://github.com/strapi/strapi) | `5.0.1` | `5.4.2` |
| [@strapi/core](https://github.com/strapi/strapi) | `5.0.1` | `5.4.2` |
| @strapi/data-transfer | `5.0.1` | `5.4.2` |
| [@strapi/database](https://github.com/strapi/strapi) | `5.0.1` | `5.4.2` |
| @strapi/design-system | `2.0.0-rc.11` | `2.0.0-rc.13` |
| [@strapi/email](https://github.com/strapi/strapi) | `5.0.1` | `5.4.2` |
| [@strapi/generators](https://github.com/strapi/strapi) | `5.0.1` | `5.4.2` |
| [@strapi/i18n](https://github.com/strapi/strapi/tree/HEAD/packages/plugins/i18n) | `5.0.1` | `5.4.2` |
| @strapi/icons | `2.0.0-rc.11` | `2.0.0-rc.13` |
| [@strapi/logger](https://github.com/strapi/strapi) | `5.0.1` | `5.4.2` |
| [@strapi/permissions](https://github.com/strapi/strapi) | `5.0.1` | `5.4.2` |
| [@strapi/provider-email-sendmail](https://github.com/strapi/strapi) | `5.0.1` | `5.4.2` |
| [@strapi/provider-upload-local](https://github.com/strapi/strapi) | `5.0.1` | `5.4.2` |
| [@strapi/review-workflows](https://github.com/strapi/strapi) | `5.0.1` | `5.4.2` |
| [@strapi/types](https://github.com/strapi/strapi) | `5.0.1` | `5.4.2` |
| [@strapi/typescript-utils](https://github.com/strapi/strapi/tree/HEAD/packages/utils/typescript) | `5.0.1` | `5.4.2` |
| @strapi/ui-primitives | `2.0.0-rc.11` | `2.0.0-rc.13` |
| [@strapi/upload](https://github.com/strapi/strapi) | `5.0.1` | `5.4.2` |
| [@strapi/utils](https://github.com/strapi/strapi) | `5.0.1` | `5.4.2` |


Updates `@strapi/plugin-users-permissions` from 5.0.1 to 5.4.2
- [Release notes](https://github.com/strapi/strapi/releases)
- [Commits](strapi/strapi@v5.0.1...v5.4.2)

Updates `@strapi/strapi` from 5.0.1 to 5.4.2
- [Release notes](https://github.com/strapi/strapi/releases)
- [Commits](strapi/strapi@v5.0.1...v5.4.2)

Updates `meilisearch` from 0.36.0 to 0.45.0
- [Release notes](https://github.com/meilisearch/meilisearch-js/releases)
- [Commits](meilisearch/meilisearch-js@v0.36.0...v0.45.0)

Updates `@strapi/admin` from 5.0.1 to 5.4.2
- [Release notes](https://github.com/strapi/strapi/releases)
- [Commits](strapi/strapi@v5.0.1...v5.4.2)

Updates `@strapi/cloud-cli` from 5.0.1 to 5.4.2
- [Release notes](https://github.com/strapi/strapi/releases)
- [Commits](strapi/strapi@v5.0.1...v5.4.2)

Updates `@strapi/content-manager` from 5.0.1 to 5.4.2
- [Release notes](https://github.com/strapi/strapi/releases)
- [Commits](strapi/strapi@v5.0.1...v5.4.2)

Updates `@strapi/content-releases` from 5.0.1 to 5.4.2
- [Release notes](https://github.com/strapi/strapi/releases)
- [Commits](strapi/strapi@v5.0.1...v5.4.2)

Updates `@strapi/content-type-builder` from 5.0.1 to 5.4.2
- [Release notes](https://github.com/strapi/strapi/releases)
- [Commits](strapi/strapi@v5.0.1...v5.4.2)

Updates `@strapi/core` from 5.0.1 to 5.4.2
- [Release notes](https://github.com/strapi/strapi/releases)
- [Commits](strapi/strapi@v5.0.1...v5.4.2)

Updates `@strapi/data-transfer` from 5.0.1 to 5.4.2

Updates `@strapi/database` from 5.0.1 to 5.4.2
- [Release notes](https://github.com/strapi/strapi/releases)
- [Commits](strapi/strapi@v5.0.1...v5.4.2)

Updates `@strapi/design-system` from 2.0.0-rc.11 to 2.0.0-rc.13

Updates `@strapi/email` from 5.0.1 to 5.4.2
- [Release notes](https://github.com/strapi/strapi/releases)
- [Commits](strapi/strapi@v5.0.1...v5.4.2)

Updates `@strapi/generators` from 5.0.1 to 5.4.2
- [Release notes](https://github.com/strapi/strapi/releases)
- [Commits](strapi/strapi@v5.0.1...v5.4.2)

Updates `@strapi/i18n` from 5.0.1 to 5.4.2
- [Release notes](https://github.com/strapi/strapi/releases)
- [Commits](https://github.com/strapi/strapi/commits/v5.4.2/packages/plugins/i18n)

Updates `@strapi/icons` from 2.0.0-rc.11 to 2.0.0-rc.13

Updates `@strapi/logger` from 5.0.1 to 5.4.2
- [Release notes](https://github.com/strapi/strapi/releases)
- [Commits](strapi/strapi@v5.0.1...v5.4.2)

Updates `@strapi/permissions` from 5.0.1 to 5.4.2
- [Release notes](https://github.com/strapi/strapi/releases)
- [Commits](strapi/strapi@v5.0.1...v5.4.2)

Updates `@strapi/provider-email-sendmail` from 5.0.1 to 5.4.2
- [Release notes](https://github.com/strapi/strapi/releases)
- [Commits](strapi/strapi@v5.0.1...v5.4.2)

Updates `@strapi/provider-upload-local` from 5.0.1 to 5.4.2
- [Release notes](https://github.com/strapi/strapi/releases)
- [Commits](strapi/strapi@v5.0.1...v5.4.2)

Updates `@strapi/review-workflows` from 5.0.1 to 5.4.2
- [Release notes](https://github.com/strapi/strapi/releases)
- [Commits](strapi/strapi@v5.0.1...v5.4.2)

Updates `@strapi/types` from 5.0.1 to 5.4.2
- [Release notes](https://github.com/strapi/strapi/releases)
- [Commits](strapi/strapi@v5.0.1...v5.4.2)

Updates `@strapi/typescript-utils` from 5.0.1 to 5.4.2
- [Release notes](https://github.com/strapi/strapi/releases)
- [Commits](https://github.com/strapi/strapi/commits/v5.4.2/packages/utils/typescript)

Updates `@strapi/ui-primitives` from 2.0.0-rc.11 to 2.0.0-rc.13

Updates `@strapi/upload` from 5.0.1 to 5.4.2
- [Release notes](https://github.com/strapi/strapi/releases)
- [Commits](strapi/strapi@v5.0.1...v5.4.2)

Updates `@strapi/utils` from 5.0.1 to 5.4.2
- [Release notes](https://github.com/strapi/strapi/releases)
- [Commits](strapi/strapi@v5.0.1...v5.4.2)

---
updated-dependencies:
- dependency-name: "@strapi/plugin-users-permissions"
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: playground
- dependency-name: "@strapi/strapi"
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: playground
- dependency-name: meilisearch
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: playground
- dependency-name: "@strapi/admin"
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: playground
- dependency-name: "@strapi/cloud-cli"
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: playground
- dependency-name: "@strapi/content-manager"
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: playground
- dependency-name: "@strapi/content-releases"
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: playground
- dependency-name: "@strapi/content-type-builder"
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: playground
- dependency-name: "@strapi/core"
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: playground
- dependency-name: "@strapi/data-transfer"
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: playground
- dependency-name: "@strapi/database"
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: playground
- dependency-name: "@strapi/design-system"
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: playground
- dependency-name: "@strapi/email"
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: playground
- dependency-name: "@strapi/generators"
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: playground
- dependency-name: "@strapi/i18n"
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: playground
- dependency-name: "@strapi/icons"
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: playground
- dependency-name: "@strapi/logger"
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: playground
- dependency-name: "@strapi/permissions"
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: playground
- dependency-name: "@strapi/provider-email-sendmail"
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: playground
- dependency-name: "@strapi/provider-upload-local"
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: playground
- dependency-name: "@strapi/review-workflows"
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: playground
- dependency-name: "@strapi/types"
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: playground
- dependency-name: "@strapi/typescript-utils"
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: playground
- dependency-name: "@strapi/ui-primitives"
  dependency-type: indirect
  update-type: version-update:semver-patch
  dependency-group: playground
- dependency-name: "@strapi/upload"
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: playground
- dependency-name: "@strapi/utils"
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: playground
...

Signed-off-by: dependabot[bot] <[email protected]>
@Ra0R
Copy link
Contributor Author

Ra0R commented Jan 2, 2025

@curquiza I rebased onto main (I hope I did it correctly).

@brunoocasali
Copy link
Member

bors merge

Copy link
Contributor

meili-bors bot commented Jan 6, 2025

@meili-bors meili-bors bot merged commit 210fa04 into meilisearch:main Jan 6, 2025
1 check 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
Development

Successfully merging this pull request may close these issues.

Hook into createMany lifecycle hook Add a debounce/throttle on document addition
5 participants