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

chore(content-releases): releases migration to v5 #20259

Open
wants to merge 24 commits into
base: v5/main
Choose a base branch
from

Conversation

Feranchz
Copy link
Contributor

@Feranchz Feranchz commented May 3, 2024

What does it do?

Migrates and apply new changes on the Content Releases plugin for v5.

Work to do

  • Fix test cases
  • Validate releases with entries with multiple relations and if validation is still working
  • Validate db lifecycles and how affected are releases (entry is deleted, discarded, etc)

* chore: migrate bulkDelete to v5

* chore: change findLocales type to accept strings array

* fix: docs prettier styles

* chore: remove console.log
@Feranchz Feranchz added pr: chore This PR contains chore tasks (cleanups, configs, tooling...) source: core:content-releases labels May 3, 2024
@Feranchz Feranchz self-assigned this May 3, 2024

This comment was marked as spam.

Copy link

vercel bot commented May 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
contributor-docs ❌ Failed (Inspect) May 28, 2024 4:31pm

Copy link
Member

@joshuaellis joshuaellis left a comment

Choose a reason for hiding this comment

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

some minor feedback on the FE tweaks, you might not have know those things were available :)

Base automatically changed from v5/bulk-publish-unpublish to v5/main May 7, 2024 14:59

type ReleaseWithPopulatedActions = Release & { actions: { count: number } };

const releaseController = {
async findMany(ctx: Koa.Context) {
async findByDocumentAttached(ctx: Koa.Context) {
Copy link
Contributor

Choose a reason for hiding this comment

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

could you add some comment or explanation of what's the responsability of this controller? 🤔
After 2 weeks of being of, I forgot a bit the logic, and I don't quite see what findByDocumentAttached means.

Maybe what confuses me is the "Attached" word

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, it feels off that the endpoint is called findByDocumentAttached, but you can send a parameter to find by documents not attached 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's true, but do you think it's worth to create a different endpoint & controller to split the 2 cases? 🤔

Comment on lines +66 to +92
const relatedReleases = await releaseService.findMany({
where: {
releasedAt: null,
releasedAt: {
$null: true,
},
actions: {
target_type: contentTypeUid,
target_id: entryId,
},
},
});

const releases = await releaseService.findMany({
where: {
$or: [
{
id: {
$notIn: relatedReleases.map((release: any) => release.id),
},
},
{
actions: null,
},
],
releasedAt: {
$null: true,
},
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe these queries could be inside the service itself.

releases.findEntryReleases({id, populate...})
releases.findNotInEntryReleases({id, ...))

You could also reduce logic here if you do something like:
releases.findDocumentReleases({documentId, locale, populate...})
releases.findNotInDocumentReleases({documentId, locale, ...))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not 100% sure about this but we can discuss it when you're back

It's true that we reduce the controller complexity but we increase the service complexity and we need to maintain and look up for breaking changes in the service but not in the controller. What I mean is: Users can use the releases service in plugins or other places so in my opinion service's API should be as simple as possible and all these functions are just different way of using the findMany that already exists in the service

@Marc-Roig
Copy link
Contributor

Don't know if it's something already fixed in the v5 branch , but it's a bit difficult for me to test strapi using multiple users atm. It's not possible for me to refresh the page when I have two tabs (one in incognito) with two different users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: chore This PR contains chore tasks (cleanups, configs, tooling...) source: core:content-releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants