<commit_before>﻿using System;
using System.Globalization;
using System.Net.Http.Formatting;
using Our.Umbraco.MigrationsViewer.Core.Services;
using umbraco.BusinessLogic.Actions;
using Umbraco.Core;
using Umbraco.Web.Models.Trees;
using Umbraco.Web.Mvc;
using Umbraco.Web.Trees;
using Umbraco.Web.WebApi.Filters;

namespace Our.Umbraco.MigrationsViewer.Core.Controllers
{
    [UmbracoApplicationAuthorize(Constants.Applications.Developer)]
    [PluginController(PluginConstants.Name)]
    [Tree(Constants.Applications.Developer, PluginConstants.Name, PluginConstants.Title)]
    public class MigrationsViewerTreeController : TreeController
    {
        private readonly IMigrationNamesService _service = new DatabaseMigrationNamesService(ApplicationContext.Current.DatabaseContext.Database);

        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            var nodes = new TreeNodeCollection();

            if (IsRoot(id) == false)
            {
                throw new NotSupportedException();
            }

            var products = _service.GetUniqueMigrationNames();

            foreach (var product in products)
            {
                var node = CreateTreeNode(product, id, null, product, "icon-tactics", false);
                nodes.Add(node);
            }<commit_msg>Tidy up Tree Node code<commit_after>﻿using System;
using System.Globalization;
using System.Net.Http.Formatting;
using Our.Umbraco.MigrationsViewer.Core.Services;
using umbraco.BusinessLogic.Actions;
using Umbraco.Core;
using Umbraco.Web.Models.Trees;
using Umbraco.Web.Mvc;
using Umbraco.Web.Trees;
using Umbraco.Web.WebApi.Filters;

namespace Our.Umbraco.MigrationsViewer.Core.Controllers
{
    [UmbracoApplicationAuthorize(Constants.Applications.Developer)]
    [PluginController(PluginConstants.Name)]
    [Tree(Constants.Applications.Developer, PluginConstants.Name, PluginConstants.Title)]
    public class MigrationsViewerTreeController : TreeController
    {
        private const string MigrationNameTreeNodeIcon = "icon-tactics";
        private readonly IMigrationNamesService _service = new DatabaseMigrationNamesService(ApplicationContext.Current.DatabaseContext.Database);

        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            var nodes = new TreeNodeCollection();

            if (IsRoot(id) == false)
            {
                throw new NotSupportedException();
            }

            var migrationNames = _service.GetUniqueMigrationNames();

            foreach (var name in migrationNames)
            {
                var node = CreateTreeNode(name, id, null, name, MigrationNameTreeNodeIcon, false);
                nodes.Add(node);
            }
{'fraction_non_alphanumeric': 0.08220157255182273, 'fraction_numerical': 0.0, 'mean_word_length': 3.3261205564142196, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5329242', 'n_tokens_mistral': 763, 'n_tokens_neox': 731, 'n_words': 151}