mattie-strapi-bundle icon indicating copy to clipboard operation
mattie-strapi-bundle copied to clipboard

Add publication state handling to lifecycle methods

Open richardweaver opened this issue 2 years ago • 2 comments

I'm proposing this change to make the plugin reactive to publication state. This means unpublished entities will not appear in the search index.

  • Create: if the entity uses draft/publish and publishedAt is null then do not index; otherwise create in index
  • Update if the entity uses draft/publish and publishedAt is null then delete from index; otherwise update in index

The update behaviour isn't the smartest because the best solution would be to detect if publication state had actually changed; but I can't figure out how to do that so I'm defensively deleting to ensure the unpublished entity is removed from the search index.

Also, in theory we could be "updating" a non existent entity in the index where this entity is being published for the first time. I know Algolia handles this because partialUpdateObject can create as well as update, but worth bearing in mind for future providers.

richardweaver avatar Aug 14 '22 17:08 richardweaver

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

1 Ignored Deployment
Name Status Preview Updated
mattie-strapi-bundle ⬜️ Ignored (Inspect) Aug 14, 2022 at 5:43PM (UTC)

vercel[bot] avatar Aug 14 '22 17:08 vercel[bot]

+1 to this feature. could you please merge it in @MattieBelt ?

alexanderscott avatar Mar 20 '23 19:03 alexanderscott