<commit_before>﻿using System.Text.RegularExpressions;

namespace RoutingVisualization
{
    public abstract class NodeStrategy
    {
        public abstract string GetNodeId(EndpointDetails details);

        public string GetNodeId(ProcessedMessage message)
        {
            return ToNodeName(GetNodeId(message.MessageMetadata.SendingEndpoint), message.Headers["NServiceBus.MessageIntent"], message.MessageMetadata.MessageType);
        }

        protected static string ToNodeName(params string[] parts)
        {
            return Regex.Replace(string.Join("_", parts), "[-.]", "_").ToLower();
        }
    }

    class PhysicalRoutingNodeStrategy : NodeStrategy
    {
        public override string GetNodeId(EndpointDetails details)<commit_msg>Collapse multiple Events from the same publisher into a single message Collapse multiple non-event messages going to the same recipient into a single message<commit_after>﻿using System.Text.RegularExpressions;

namespace RoutingVisualization
{
    public abstract class NodeStrategy
    {
        public abstract string GetNodeId(EndpointDetails details);

        public string GetNodeId(ProcessedMessage message)
        {
            var intent = message.Headers["NServiceBus.MessageIntent"];

            if (intent == "Publish")
            {
                return ToNodeName(GetNodeId(message.MessageMetadata.SendingEndpoint), intent,
                    message.MessageMetadata.MessageType);
            }
            else
            {
                return ToNodeName(GetNodeId(message.MessageMetadata.ReceivingEndpoint), intent,
                    message.MessageMetadata.MessageType);
            }

            //return ToNodeName(GetNodeId(message.MessageMetadata.SendingEndpoint), intent, message.MessageMetadata.MessageType);
        }

        protected static string ToNodeName(params string[] parts)
        {
            return Regex.Replace(string.Join("_", parts), "[-.]", "_").ToLower();
        }
    }

    class PhysicalRoutingNodeStrategy : NodeStrategy
    {
        public override string GetNodeId(EndpointDetails details)
{'fraction_non_alphanumeric': 0.08100426338228328, 'fraction_numerical': 0.0, 'mean_word_length': 2.7714285714285714, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4583623', 'n_tokens_mistral': 504, 'n_tokens_neox': 489, 'n_words': 115}