V10/feature/content schedule performance (#11398)
* Nuke Content.ContentSchedule Can't make an omelette without breaking eggs * Fix read view models * Fix Save, Save & Schedule, Save & Publish * Fix scheduled publish/unpublish * Fix unit tests * Fix bugs & integration tests * Cleanup action result signatures * Update tests from #11356, new method for saving contentschedule
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Umbraco.
|
||||
// Copyright (c) Umbraco.
|
||||
// See LICENSE for more details.
|
||||
|
||||
using System;
|
||||
@@ -39,8 +39,8 @@ namespace Umbraco.Cms.Tests.Integration.Testing
|
||||
|
||||
// Create and Save Content "Text Page 1" based on "umbTextpage" -> 1054
|
||||
Subpage = ContentBuilder.CreateSimpleContent(ContentType, "Text Page 1", Textpage.Id);
|
||||
Subpage.ContentSchedule.Add(DateTime.Now.AddMinutes(-5), null);
|
||||
ContentService.Save(Subpage, 0);
|
||||
var contentSchedule = ContentScheduleCollection.CreateWithEntry(DateTime.Now.AddMinutes(-5), null);
|
||||
ContentService.Save(Subpage, 0, contentSchedule);
|
||||
|
||||
// Create and Save Content "Text Page 1" based on "umbTextpage" -> 1055
|
||||
Subpage2 = ContentBuilder.CreateSimpleContent(ContentType, "Text Page 2", Textpage.Id);
|
||||
|
||||
@@ -224,14 +224,17 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Services
|
||||
c.Name = "name" + i;
|
||||
if (i % 2 == 0)
|
||||
{
|
||||
c.ContentSchedule.Add(now.AddSeconds(5), null); // release in 5 seconds
|
||||
OperationResult r = ContentService.Save(c);
|
||||
var contentSchedule = ContentScheduleCollection.CreateWithEntry(now.AddSeconds(5), null); // release in 5 seconds
|
||||
OperationResult r = ContentService.Save(c, contentSchedule: contentSchedule);
|
||||
Assert.IsTrue(r.Success, r.Result.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
c.ContentSchedule.Add(null, now.AddSeconds(5)); // expire in 5 seconds
|
||||
PublishResult r = ContentService.SaveAndPublish(c);
|
||||
|
||||
var contentSchedule = ContentScheduleCollection.CreateWithEntry(null, now.AddSeconds(5)); // expire in 5 seconds
|
||||
ContentService.PersistContentSchedule(c, contentSchedule);
|
||||
|
||||
Assert.IsTrue(r.Success, r.Result.ToString());
|
||||
}
|
||||
|
||||
@@ -249,16 +252,19 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Services
|
||||
|
||||
if (i % 2 == 0)
|
||||
{
|
||||
c.ContentSchedule.Add(alternatingCulture, now.AddSeconds(5), null); // release in 5 seconds
|
||||
OperationResult r = ContentService.Save(c);
|
||||
var contentSchedule = ContentScheduleCollection.CreateWithEntry(alternatingCulture, now.AddSeconds(5), null); // release in 5 seconds
|
||||
OperationResult r = ContentService.Save(c, contentSchedule: contentSchedule);
|
||||
Assert.IsTrue(r.Success, r.Result.ToString());
|
||||
|
||||
alternatingCulture = alternatingCulture == langFr.IsoCode ? langUk.IsoCode : langFr.IsoCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
c.ContentSchedule.Add(alternatingCulture, null, now.AddSeconds(5)); // expire in 5 seconds
|
||||
PublishResult r = ContentService.SaveAndPublish(c);
|
||||
|
||||
var contentSchedule = ContentScheduleCollection.CreateWithEntry(alternatingCulture, null, now.AddSeconds(5)); // expire in 5 seconds
|
||||
ContentService.PersistContentSchedule(c, contentSchedule);
|
||||
|
||||
Assert.IsTrue(r.Success, r.Result.ToString());
|
||||
}
|
||||
|
||||
@@ -307,20 +313,20 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Services
|
||||
// Act
|
||||
IContent content = ContentService.CreateAndSave("Test", Constants.System.Root, "umbTextpage", Constants.Security.SuperUserId);
|
||||
|
||||
content.ContentSchedule.Add(null, DateTime.Now.AddHours(2));
|
||||
ContentService.Save(content, Constants.Security.SuperUserId);
|
||||
Assert.AreEqual(1, content.ContentSchedule.FullSchedule.Count);
|
||||
var contentSchedule = ContentScheduleCollection.CreateWithEntry(null, DateTime.Now.AddHours(2));
|
||||
ContentService.Save(content, Constants.Security.SuperUserId, contentSchedule);
|
||||
Assert.AreEqual(1, contentSchedule.FullSchedule.Count);
|
||||
|
||||
content = ContentService.GetById(content.Id);
|
||||
IReadOnlyList<ContentSchedule> sched = content.ContentSchedule.FullSchedule;
|
||||
contentSchedule = ContentService.GetContentScheduleByContentId(content.Id);
|
||||
IReadOnlyList<ContentSchedule> sched = contentSchedule.FullSchedule;
|
||||
Assert.AreEqual(1, sched.Count);
|
||||
Assert.AreEqual(1, sched.Count(x => x.Culture == string.Empty));
|
||||
content.ContentSchedule.Clear(ContentScheduleAction.Expire);
|
||||
ContentService.Save(content, Constants.Security.SuperUserId);
|
||||
contentSchedule.Clear(ContentScheduleAction.Expire);
|
||||
ContentService.Save(content, Constants.Security.SuperUserId, contentSchedule);
|
||||
|
||||
// Assert
|
||||
content = ContentService.GetById(content.Id);
|
||||
sched = content.ContentSchedule.FullSchedule;
|
||||
contentSchedule = ContentService.GetContentScheduleByContentId(content.Id);
|
||||
sched = contentSchedule.FullSchedule;
|
||||
Assert.AreEqual(0, sched.Count);
|
||||
Assert.IsTrue(ContentService.SaveAndPublish(content).Success);
|
||||
}
|
||||
@@ -646,7 +652,8 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Services
|
||||
IContent root = ContentService.GetById(Textpage.Id);
|
||||
ContentService.SaveAndPublish(root);
|
||||
IContent content = ContentService.GetById(Subpage.Id);
|
||||
content.ContentSchedule.Add(null, DateTime.Now.AddSeconds(1));
|
||||
var contentSchedule = ContentScheduleCollection.CreateWithEntry(null, DateTime.Now.AddSeconds(1));
|
||||
ContentService.PersistContentSchedule(content, contentSchedule);
|
||||
ContentService.SaveAndPublish(content);
|
||||
|
||||
// Act
|
||||
@@ -1292,8 +1299,8 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Services
|
||||
{
|
||||
// Arrange
|
||||
IContent content = ContentService.GetById(Subpage.Id); // This Content expired 5min ago
|
||||
content.ContentSchedule.Add(null, DateTime.Now.AddMinutes(-5));
|
||||
ContentService.Save(content);
|
||||
var contentSchedule = ContentScheduleCollection.CreateWithEntry(null, DateTime.Now.AddMinutes(-5));
|
||||
ContentService.Save(content, contentSchedule: contentSchedule);
|
||||
|
||||
IContent parent = ContentService.GetById(Textpage.Id);
|
||||
PublishResult parentPublished = ContentService.SaveAndPublish(parent, userId: Constants.Security.SuperUserId); // Publish root Home node to enable publishing of 'Subpage.Id'
|
||||
@@ -1317,8 +1324,8 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Services
|
||||
|
||||
Content content = ContentBuilder.CreateBasicContent(contentType);
|
||||
content.SetCultureName("Hello", "en-US");
|
||||
content.ContentSchedule.Add("en-US", null, DateTime.Now.AddMinutes(-5));
|
||||
ContentService.Save(content);
|
||||
var contentSchedule = ContentScheduleCollection.CreateWithEntry("en-US", null, DateTime.Now.AddMinutes(-5));
|
||||
ContentService.Save(content, contentSchedule: contentSchedule);
|
||||
|
||||
PublishResult published = ContentService.SaveAndPublish(content, "en-US", Constants.Security.SuperUserId);
|
||||
|
||||
@@ -1332,8 +1339,8 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Services
|
||||
{
|
||||
// Arrange
|
||||
IContent content = ContentService.GetById(Subpage.Id);
|
||||
content.ContentSchedule.Add(DateTime.Now.AddHours(2), null);
|
||||
ContentService.Save(content, Constants.Security.SuperUserId);
|
||||
var contentSchedule = ContentScheduleCollection.CreateWithEntry(DateTime.Now.AddHours(2), null);
|
||||
ContentService.Save(content, Constants.Security.SuperUserId, contentSchedule);
|
||||
|
||||
IContent parent = ContentService.GetById(Textpage.Id);
|
||||
PublishResult parentPublished = ContentService.SaveAndPublish(parent, userId: Constants.Security.SuperUserId); // Publish root Home node to enable publishing of 'Subpage.Id'
|
||||
@@ -1380,8 +1387,8 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Services
|
||||
contentService.SaveAndPublish(content);
|
||||
|
||||
content.Properties[0].SetValue("Foo", culture: string.Empty);
|
||||
content.ContentSchedule.Add(DateTime.Now.AddHours(2), null);
|
||||
contentService.Save(content);
|
||||
contentService.PersistContentSchedule(content, ContentScheduleCollection.CreateWithEntry(DateTime.Now.AddHours(2), null));
|
||||
|
||||
// Act
|
||||
var result = contentService.SaveAndPublish(content, userId: Constants.Security.SuperUserId);
|
||||
@@ -1430,7 +1437,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Services
|
||||
|
||||
contentService.SaveAndPublish(content);
|
||||
|
||||
content.ContentSchedule.Add(DateTime.Now.AddHours(2), null);
|
||||
contentService.PersistContentSchedule(content, ContentScheduleCollection.CreateWithEntry(DateTime.Now.AddHours(2), null));
|
||||
contentService.Save(content);
|
||||
|
||||
// Act
|
||||
@@ -1458,8 +1465,8 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Services
|
||||
|
||||
Content content = ContentBuilder.CreateBasicContent(contentType);
|
||||
content.SetCultureName("Hello", "en-US");
|
||||
content.ContentSchedule.Add("en-US", DateTime.Now.AddHours(2), null);
|
||||
ContentService.Save(content);
|
||||
var contentSchedule = ContentScheduleCollection.CreateWithEntry("en-US", DateTime.Now.AddHours(2), null);
|
||||
ContentService.Save(content, contentSchedule: contentSchedule);
|
||||
|
||||
PublishResult published = ContentService.SaveAndPublish(content, "en-US", Constants.Security.SuperUserId);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Umbraco.
|
||||
// Copyright (c) Umbraco.
|
||||
// See LICENSE for more details.
|
||||
|
||||
using System;
|
||||
@@ -809,8 +809,8 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Services
|
||||
|
||||
// Create and Save Content "Text Page 1" based on "umbTextpage" -> 1054
|
||||
_subpage = ContentBuilder.CreateSimpleContent(_contentType, "Text Page 1", _textpage.Id);
|
||||
_subpage.ContentSchedule.Add(DateTime.Now.AddMinutes(-5), null);
|
||||
ContentService.Save(_subpage, 0);
|
||||
var contentSchedule = ContentScheduleCollection.CreateWithEntry(DateTime.Now.AddMinutes(-5), null);
|
||||
ContentService.Save(_subpage, 0, contentSchedule);
|
||||
|
||||
// Create and Save Content "Text Page 2" based on "umbTextpage" -> 1055
|
||||
_subpage2 = ContentBuilder.CreateSimpleContent(_contentType, "Text Page 2", _textpage.Id);
|
||||
|
||||
@@ -253,8 +253,6 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Models
|
||||
content.Key = Guid.NewGuid();
|
||||
content.Level = 3;
|
||||
content.Path = "-1,4,10";
|
||||
content.ContentSchedule.Add(DateTime.Now, DateTime.Now.AddDays(1));
|
||||
//// content.ChangePublishedState(PublishedState.Published);
|
||||
content.SortOrder = 5;
|
||||
content.TemplateId = 88;
|
||||
content.Trashed = false;
|
||||
@@ -316,7 +314,6 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Models
|
||||
content.Key = Guid.NewGuid();
|
||||
content.Level = 3;
|
||||
content.Path = "-1,4,10";
|
||||
content.ContentSchedule.Add(DateTime.Now, DateTime.Now.AddDays(1));
|
||||
content.SortOrder = 5;
|
||||
content.TemplateId = 88;
|
||||
content.Trashed = false;
|
||||
@@ -338,7 +335,6 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Models
|
||||
Assert.AreEqual(clone.Key, content.Key);
|
||||
Assert.AreEqual(clone.Level, content.Level);
|
||||
Assert.AreEqual(clone.Path, content.Path);
|
||||
Assert.IsTrue(clone.ContentSchedule.Equals(content.ContentSchedule));
|
||||
Assert.AreEqual(clone.Published, content.Published);
|
||||
Assert.AreEqual(clone.PublishedState, content.PublishedState);
|
||||
Assert.AreEqual(clone.SortOrder, content.SortOrder);
|
||||
@@ -421,7 +417,6 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Models
|
||||
content.Id = 10;
|
||||
content.CreateDate = DateTime.Now;
|
||||
content.CreatorId = 22;
|
||||
content.ContentSchedule.Add(DateTime.Now, DateTime.Now.AddDays(1));
|
||||
content.Key = Guid.NewGuid();
|
||||
content.Level = 3;
|
||||
content.Path = "-1,4,10";
|
||||
@@ -442,7 +437,6 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Models
|
||||
Assert.IsTrue(content.WasPropertyDirty(nameof(Content.Key)));
|
||||
Assert.IsTrue(content.WasPropertyDirty(nameof(Content.Level)));
|
||||
Assert.IsTrue(content.WasPropertyDirty(nameof(Content.Path)));
|
||||
Assert.IsTrue(content.WasPropertyDirty(nameof(Content.ContentSchedule)));
|
||||
Assert.IsTrue(content.WasPropertyDirty(nameof(Content.SortOrder)));
|
||||
Assert.IsTrue(content.WasPropertyDirty(nameof(Content.TemplateId)));
|
||||
Assert.IsTrue(content.WasPropertyDirty(nameof(Content.Trashed)));
|
||||
@@ -492,8 +486,6 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Models
|
||||
content.Key = Guid.NewGuid();
|
||||
content.Level = 3;
|
||||
content.Path = "-1,4,10";
|
||||
content.ContentSchedule.Add(DateTime.Now, DateTime.Now.AddDays(1));
|
||||
//// content.ChangePublishedState(PublishedState.Publishing);
|
||||
content.SortOrder = 5;
|
||||
content.TemplateId = 88;
|
||||
content.Trashed = false;
|
||||
|
||||
Reference in New Issue
Block a user