From 658a5601a5c4aa8170cd332a2476decc59ce693b Mon Sep 17 00:00:00 2001 From: mvarblow Date: Fri, 18 Sep 2015 10:42:54 -0400 Subject: [PATCH] Update TermsPartHandler.cs Queue a single task to process all terms updated within this work context. --- .../Handlers/TermsPartHandler.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Taxonomies/Handlers/TermsPartHandler.cs b/src/Orchard.Web/Modules/Orchard.Taxonomies/Handlers/TermsPartHandler.cs index b1ea5d2c0..94d51b766 100644 --- a/src/Orchard.Web/Modules/Orchard.Taxonomies/Handlers/TermsPartHandler.cs +++ b/src/Orchard.Web/Modules/Orchard.Taxonomies/Handlers/TermsPartHandler.cs @@ -17,6 +17,8 @@ namespace Orchard.Taxonomies.Handlers { public class TermsPartHandler : ContentHandler { private readonly IContentDefinitionManager _contentDefinitionManager; private readonly IContentManager _contentManager; + + private readonly HashSet _processedTermParts = new HashSet(); public TermsPartHandler( IContentDefinitionManager contentDefinitionManager, @@ -88,12 +90,16 @@ namespace Orchard.Taxonomies.Handlers { }); } - - // Fires off a processing engine task to run the count processing after the request so it's non-blocking. + // Fires off a processing engine task to run the count processing after the request so it's non-blocking. private void RecalculateCount(IProcessingEngine processingEngine, ShellSettings shellSettings, IShellDescriptorManager shellDescriptorManager, TermsPart part) { var termPartRecordIds = part.Terms.Select(t => t.TermRecord.Id).ToArray(); - if (termPartRecordIds.Length > 0) { - processingEngine.AddTask(shellSettings, shellDescriptorManager.GetShellDescriptor(), "ITermCountProcessor.Process", new Dictionary { { "termPartRecordIds", termPartRecordIds } }); + if (termPartRecordIds.Any()) { + if (!_processedTermParts.Any()) { + processingEngine.AddTask(shellSettings, shellDescriptorManager.GetShellDescriptor(), "ITermCountProcessor.Process", new Dictionary { { "termPartRecordIds", _processedTermParts } }); + } + foreach (var termPartRecordId in termPartRecordIds) { + _processedTermParts.Add(termPartRecordId); + } } }