Can Source Code RecalculateCount be Updated to Recount Parent Terms

Feb 20, 2012 at 12:49 PM


I was working with your taxonomy module and noticed that "parent terms" were not automatically being updated when a child termw as updated. This was a functionality that I was expecting it to do so I went ahead and modified "TermsPartHandler.cs" file, "RecalculateCount" method as seen here:

private static void RecalculateCount(IContentManager contentManager, ITaxonomyService taxonomyService, TermsPart part) {
    // submits any change to the db so that GetContentItemsCount is accurate

    foreach (var term in part.Terms) {
        var termPart = taxonomyService.GetTerm(term.TermRecord.Id);
        term.TermRecord.Count = (int)taxonomyService.GetContentItemsCount(termPart);

        // ADDED BY EMS start
        // Also want to recount parent terms...
        var termParents = taxonomyService.GetParents(termPart);
        foreach (var termParent in termParents) {
            termParent.Record.Count = (int)taxonomyService.GetContentItemsCount(termParent);
        // ADDED BY EMS end


I was wondering if you feel this is worthy to be part of the source code. Perhaps it should have an associated setting that the user would check to indicate whether they wanted parent terms to include the childrent count so the user can decide.  Thanks for your consideration in this regard.