Skip to content

Commit ec7345f

Browse files
committed
Complete implementation of tree sign for pending scheduled publish.
1 parent 949b163 commit ec7345f

File tree

4 files changed

+50
-2
lines changed

4 files changed

+50
-2
lines changed

src/Umbraco.Core/Persistence/Repositories/IDocumentRepository.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ public interface IDocumentRepository : IContentRepository<int, IContent>, IReadR
5050
/// </remarks>
5151
IEnumerable<IContent> GetContentForRelease(DateTime date);
5252

53+
/// <summary>
54+
/// Gets the content Ids from the provided collection of content Ids that are scheduled for publishing.
55+
/// </summary>
56+
/// <param name="keys">The content keys.</param>
57+
/// <returns>
58+
/// The provided collection of content Ids filtered for those that are scheduled for publishing.
59+
/// </returns>
60+
IEnumerable<Guid> GetScheduledContentKeys(Guid[] keys) => [];
61+
5362
/// <summary>
5463
/// Get the count of published items
5564
/// </summary>

src/Umbraco.Core/Services/ContentService.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,23 @@ public IEnumerable<IContent> GetPagedContentInRecycleBin(long pageIndex, int pag
10071007
/// <returns>True if the content has any children otherwise False</returns>
10081008
public bool HasChildren(int id) => CountChildren(id) > 0;
10091009

1010+
1011+
/// <inheritdoc/>
1012+
public IEnumerable<Guid> GetScheduledContentKeys(IEnumerable<Guid> keys)
1013+
{
1014+
Guid[] idsA = keys.ToArray();
1015+
if (idsA.Length == 0)
1016+
{
1017+
return Enumerable.Empty<Guid>();
1018+
}
1019+
1020+
using (ICoreScope scope = ScopeProvider.CreateCoreScope(autoComplete: true))
1021+
{
1022+
scope.ReadLock(Constants.Locks.ContentTree);
1023+
return _documentRepository.GetScheduledContentKeys(idsA);
1024+
}
1025+
}
1026+
10101027
/// <summary>
10111028
/// Checks if the passed in <see cref="IContent" /> can be published based on the ancestors publish state.
10121029
/// </summary>

src/Umbraco.Core/Services/IContentService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,11 @@ IContent CreateBlueprintFromContent(IContent blueprint, string name, int userId
278278
/// <summary>
279279
/// Gets the content Ids from the provided collection of content Ids that are scheduled for publishing.
280280
/// </summary>
281-
/// <param name="keys">The content keys </param>
281+
/// <param name="keys">The content keys.</param>
282282
/// <returns>
283283
/// The provided collection of content Ids filtered for those that are scheduled for publishing.
284284
/// </returns>
285-
IEnumerable<Guid> GetScheduledContentKeys(IEnumerable<Guid> keys) => keys.Count() > 0 ? [keys.First()] : [];
285+
IEnumerable<Guid> GetScheduledContentKeys(IEnumerable<Guid> keys) => [];
286286

287287
#endregion
288288

src/Umbraco.Infrastructure/Persistence/Repositories/Implement/DocumentRepository.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Globalization;
22
using Microsoft.Extensions.Logging;
33
using NPoco;
4+
using Org.BouncyCastle.Crypto;
45
using Umbraco.Cms.Core;
56
using Umbraco.Cms.Core.Cache;
67
using Umbraco.Cms.Core.Events;
@@ -1671,6 +1672,27 @@ public IEnumerable<IContent> GetContentForRelease(DateTime date)
16711672
return MapDtosToContent(Database.Fetch<DocumentDto>(sql));
16721673
}
16731674

1675+
/// <inheritdoc />
1676+
public IEnumerable<Guid> GetScheduledContentKeys(Guid[] keys)
1677+
{
1678+
var action = ContentScheduleAction.Release.ToString();
1679+
DateTime now = DateTime.UtcNow;
1680+
1681+
Sql<ISqlContext> sql = SqlContext.Sql();
1682+
sql
1683+
.Select<NodeDto>(x => x.UniqueId)
1684+
.From<DocumentDto>()
1685+
.InnerJoin<ContentDto>().On<DocumentDto, ContentDto>(left => left.NodeId, right => right.NodeId)
1686+
.InnerJoin<NodeDto>().On<ContentDto, NodeDto>(left => left.NodeId, right => right.NodeId)
1687+
.WhereIn<NodeDto>(x => x.UniqueId, keys)
1688+
.WhereIn<NodeDto>(x => x.NodeId, Sql()
1689+
.Select<ContentScheduleDto>(x => x.NodeId)
1690+
.From<ContentScheduleDto>()
1691+
.Where<ContentScheduleDto>(x => x.Action == action && x.Date >= now));
1692+
1693+
return Database.Fetch<Guid>(sql);
1694+
}
1695+
16741696
/// <inheritdoc />
16751697
public IEnumerable<IContent> GetContentForExpiration(DateTime date)
16761698
{

0 commit comments

Comments
 (0)