Performance: Add create-and-publish and update-and-publish endpoints#21284
Draft
AndyButland wants to merge 6 commits intomainfrom
Draft
Performance: Add create-and-publish and update-and-publish endpoints#21284AndyButland wants to merge 6 commits intomainfrom
AndyButland wants to merge 6 commits intomainfrom
Conversation
…ted, skipping validation, and DRY up the creation of the content schedule data.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds new Management API endpoints to combine create/update and publish operations into single requests, improving efficiency and developer experience. The changes introduce create-and-publish and update-and-publish endpoints that perform both operations atomically, along with a new PublishAsync overload that accepts an already-loaded content entity to avoid redundant database lookups.
Key Changes
- New combined operation endpoints that perform create/update and immediate publish in one request
- Service layer optimization with an
IContentoverload that skips redundant database queries - Extracted
BuildCultureAndScheduleModelhelper method to reduce code duplication in the service layer
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| CreateAndPublishDocumentController.cs | New controller providing POST endpoint to create and immediately publish documents in a single request |
| UpdateAndPublishDocumentController.cs | New controller providing PUT endpoint to update and immediately publish documents in a single request |
| CreateAndPublishDocumentRequestModel.cs | Request model extending CreateDocumentRequestModel with cultures property for immediate publishing |
| UpdateAndPublishDocumentRequestModel.cs | Request model extending UpdateDocumentRequestModel with cultures property for immediate publishing |
| IContentPublishingService.cs | Added new PublishAsync overload accepting IContent entity with skipValidation parameter to avoid database round-trips |
| ContentPublishingService.cs | Implemented new PublishAsync overload and extracted BuildCultureAndScheduleModel helper method for code reuse |
| ContentPublishingServiceTests.Publish.cs | Added comprehensive tests for the new PublishAsync overload with skipValidation parameter |
| PublishDocumentRequestModel.cs | Removed extra blank line (formatting cleanup) |
| PublishDocumentController.cs | Removed unused import statement (code cleanup) |
src/Umbraco.Cms.Api.Management/Controllers/Document/CreateAndPublishDocumentController.cs
Show resolved
Hide resolved
src/Umbraco.Cms.Api.Management/Controllers/Document/UpdateAndPublishDocumentController.cs
Show resolved
Hide resolved
src/Umbraco.Cms.Api.Management/Controllers/Document/CreateAndPublishDocumentController.cs
Outdated
Show resolved
Hide resolved
src/Umbraco.Cms.Api.Management/Controllers/Document/CreateAndPublishDocumentController.cs
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
With Umbraco 14+ we've split the save and publish operation into two. As a performance improvement, we might consider new API endpoints that perform create/update and publish in one operation, similar to how we do in Umbraco 13 - which may give us some options for optimization.
I've done that in a fairly simple way in this PR. Testing comparing the API calls of separate save and publish versus combined doesn't suggest much value - around 3% in a rough test - but there may be more we could do here. For now the only optimizations I've found are in:
It feels like any further benefit would require a larger change at the service level - and mean we'd have to blur the nice split we currently have between the
IContentEditingServiceandIContentPublishingService. If we did that for example we could look at putting the whole operation in a single lock and scope.If we move forward with this, there's still a task needed to actually use the new API endpoints from the backoffice.
Change Summary
POST /document/create-and-publish- Creates a document and immediately publishes itPUT /document/{id}/update-and-publish- Updates a document and immediately publishes itPublishAsync(IContent, ...)overload toIContentPublishingServicethat accepts an already-loaded content entity, avoiding an extra database round-tripskipValidationparameter to skip redundant validation when the caller has already validated the contentBuildCultureAndScheduleModelhelper method to DRY up schedule model creationReview and Testing
create-and-publishendpoint creates and publishes a document in a single requestupdate-and-publishendpoint updates and publishes a document in a single request