<commit_before>﻿@using System.Xml
@using System.Xml.Linq

@functions {
    int errors = 0, warnings = 0;
    
    string GetAnnotations(string type)
    {
        switch (type)
        {
            case "error":
                return "label-important";
            case "warning":
                return "label-warning";
            default:
                break;
        }

        return "label-info";
    }
}

@helper RenderElement(XElement element)
    {
    var typeAttr = element.Attribute("type");
    if (typeAttr != null)
    {
        var cssCls = GetAnnotations(typeAttr.Value);
        <li class="step @typeAttr.Value">            
            <div class="label @cssCls title">
                @if (element.Elements().Any()) { 
                <span class="more icon-white icon-chevron-down"></span>
                }
                @if (typeAttr.Value == "lock") { 
                    <i class="icon-white icon-lock"></i>
                }
                @element.Attribute("title").Value - @element.Attribute("date").Value
                @if (element.Attribute("elapsed").Value != "0")
                { 
                    <text>, took @element.Attribute("elapsed").Value ms</text> 
                }
           </div>
        @switch (typeAttr.Value)
        {
            case "request":
                if (element.Attribute("git") != null)
                { 
                <span class="label label-success">git</span>
                }
                <span class="req-method">@element.Attribute("method").Value</span> @element.Attribute("url").Value
                break;
            case "process":
                <pre>@element.Attribute("path").Value @element.Attribute("arguments").Value</pre>
                break;
            case "error":
                errors++;
                if (element.Attribute("text") != null)
                { 
                <pre>@element.Attribute("text").Value</pre>
                }
                break;
            case "warning":
                warnings++;                
                if (element.Attribute("text") != null)
                { 
                <pre>@element.Attribute("text").Value</pre>
                }
                break;
            case "processOutput":
                var os = element.Attribute("outStream").Value;
                var es = element.Attribute("errorStream").Value;
                if (!String.IsNullOrEmpty(os))
                { 
                <div class="out-stream">output stream</div>
                <pre>@os</pre>
                }
                if (!String.IsNullOrEmpty(es))
                { 
                <div class="err-stream">error stream</div>
                <pre>@es</pre>
                }
                break;
        }
        @RenderElements(element.Elements())    
        </li>        
    }
    else
    {
        <li class="step">
            <div class="label title">
                @if (element.Elements().Any())
                { 
                <span class="more icon-white icon-chevron-down"></span>
                }
                @element.Attribute("title").Value - @element.Attribute("date").Value, took @element.Attribute("elapsed").Value ms
            </div>
            @RenderElements(element.Elements())
        </li>        
    }
}

@helper RenderElements(IEnumerable<XElement> elements)
{
        var filtered = elements.Where(e => e.Attribute("date") != null);
        var sorted = filtered.OrderBy(e => DateTime.ParseExact(e.Attribute("date").Value, "MM/dd H:mm:ss", System.Globalization.CultureInfo.CurrentCulture));
        foreach (var e in sorted)
        {
    <ul>
        @RenderElement(e)
    </ul>
        }
}


@if (Model != null)
{
    var result = RenderElements(Model.Root.Elements()).ToString();
    <h3>Analysis</h3>
    <p>
        <span class="badge badge-error">@errors</span> Errors <span class="badge badge-warning">@warnings</span> Warnings
    </p>
    <div class="analysis">
        @Html.Raw(result)
    </div>
}

<script type="text/javascript">
    $(function () {
        $('.title ').toggle(function () {
            var $this = $(this);
            var $icon = $this.find('.more');
            $this.parent().children('ul').hide();
            $icon.addClass('icon-chevron-up');
            $icon.removeClass('icon-chevron-down');
        },
        function () {
            var $this = $(this);
            var $icon = $this.find('.more');
            $this.parent().children('ul').show();
            $icon.removeClass('icon-chevron-up');
            $icon.addClass('icon-chevron-down');
        });

        $('.toggle').click(function () {
            $('.step').click();
        });
    });
</script><commit_msg>Allow for quickly detecting warnings and errors in trace.<commit_after>﻿@using System.Xml
@using System.Xml.Linq

@functions {
    int errors = 0, warnings = 0;
    
    string GetAnnotations(string type)
    {
        switch (type)
        {
            case "error":
                return "label-important";
            case "warning":
                return "label-warning";
            default:
                break;
        }

        return "label-info";
    }
}

@helper RenderElement(XElement element)
    {
    var typeAttr = element.Attribute("type");
    if (typeAttr != null)
    {
        var cssCls = GetAnnotations(typeAttr.Value);
        <li class="step @typeAttr.Value">            
            <div class="label @cssCls title">
                @if (element.Elements().Any()) { 
                <span class="more icon-white icon-chevron-down"></span>
                }
                @if (typeAttr.Value == "lock") { 
                    <i class="icon-white icon-lock"></i>
                }
                @element.Attribute("title").Value - @element.Attribute("date").Value
                @if (element.Attribute("elapsed").Value != "0")
                { 
                    <text>, took @element.Attribute("elapsed").Value ms</text> 
                }
           </div>
        @switch (typeAttr.Value)
        {
            case "request":
                if (element.Attribute("git") != null)
                { 
                <span class="label label-success">git</span>
                }
                <span class="req-method">@element.Attribute("method").Value</span> @element.Attribute("url").Value
                break;
            case "process":
                <pre>@element.Attribute("path").Value @element.Attribute("arguments").Value</pre>
                break;
            case "error":
                errors++;
                if (element.Attribute("text") != null)
                { 
                <pre>@element.Attribute("text").Value</pre>
                }
                break;
            case "warning":
                warnings++;                
                if (element.Attribute("text") != null)
                { 
                <pre>@element.Attribute("text").Value</pre>
                }
                break;
            case "processOutput":
                var os = element.Attribute("outStream").Value;
                var es = element.Attribute("errorStream").Value;
                if (!String.IsNullOrEmpty(os))
                { 
                <div class="out-stream">output stream</div>
                <pre>@os</pre>
                }
                if (!String.IsNullOrEmpty(es))
                { 
                <div class="err-stream">error stream</div>
                <pre>@es</pre>
                }
                break;
        }
        @RenderElements(element.Elements())    
        </li>        
    }
    else
    {
        <li class="step">
            <div class="label title">
                @if (element.Elements().Any())
                { 
                <span class="more icon-white icon-chevron-down"></span>
                }
                @element.Attribute("title").Value - @element.Attribute("date").Value, took @element.Attribute("elapsed").Value ms
            </div>
            @RenderElements(element.Elements())
        </li>        
    }
}

@helper RenderElements(IEnumerable<XElement> elements)
{
        var filtered = elements.Where(e => e.Attribute("date") != null);
        var sorted = filtered.OrderBy(e => DateTime.ParseExact(e.Attribute("date").Value, "MM/dd H:mm:ss", System.Globalization.CultureInfo.CurrentCulture));
        foreach (var e in sorted)
        {
    <ul>
        @RenderElement(e)
    </ul>
        }
}


@if (Model != null)
{
    var result = RenderElements(Model.Root.Elements()).ToString();
    <h3>Analysis</h3>
    <p>
        <span class="all-errors badge badge-error">@errors</span> Errors <span class="all-warnings badge badge-warning">@warnings</span> Warnings
    </p>
    <div class="analysis">
        @Html.Raw(result)
    </div>
}

<script type="text/javascript">
    $(function () {
        $('.title ').toggle(function () {
            var $this = $(this);
            var $icon = $this.find('.more');
            $this.parent().children('ul').hide();
            $icon.addClass('icon-chevron-up');
            $icon.removeClass('icon-chevron-down');
        },
        function () {
            var $this = $(this);
            var $icon = $this.find('.more');
            $this.parent().children('ul').show();
            $icon.removeClass('icon-chevron-up');
            $icon.addClass('icon-chevron-down');
        });

        $('.all-warnings').toggle(function () {
            if ($(this).text() == '0') {
                return;
            }

            var $step = $('.step');
            $step.show();
            $step.not('.warning').hide();
            $('.warning').parents('li.step').show();
        },
        function () {
            $('.step').show();
        });

        $('.all-errors').toggle(function () {
            if ($(this).text() == '0') {
                return;
            }
            var $step = $('.step');
            $step.show();
            $step.not('.error').hide();
            $('.error').parents('li.step').show();
        },
        function () {
            $('.step').show();
        });

        $('.toggle').click(function () {
            $('.step').click();
        });
    });
</script>
{'fraction_non_alphanumeric': 0.15798729848558868, 'fraction_numerical': 0.001172447484123107, 'mean_word_length': 1.4296225967244245, 'pattern_counts': {'":': 14, '<': 101, '<?xml version=': 0, '>': 105, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5885911', 'n_tokens_mistral': 2818, 'n_tokens_neox': 2681, 'n_words': 469}