<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;

using Hadouken.Configuration;
using Hadouken.Http;
using Hadouken.Reflection;
using Hadouken.Data.Models;

namespace Hadouken.Impl.Http.Api
{
    [ApiAction("getsettings")]
    public class GetSettings : ApiAction
    {
        private IKeyValueStore _data;

        public GetSettings(IKeyValueStore data)
        {
            _data = data;
        }

        public override ActionResult Execute()
        {
            return Json(
                new
                {
                    version = typeof(Kernel).Assembly.GetAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion,
                    settings = (from setting in _data.Get(s => true)
                                select new object[]
                                {
                                    setting.Key,
                                    GetSettingType(setting.Value.GetType()),
                                    setting.Value,
                                    new {
                                        access = -1
                                    }
                                })
                }
            );
        }

        private int GetSettingType(Type clrType)
        {
            switch (clrType.FullName)
            {
                case "System.Int32":
                    return 0;

                case "System.Boolean":
                    return 1;

                case "System.String":
                    return 2;

                default: // unknown (to webui)
                    throw new NotImplementedException(String.Format("Unknown Web UI type {0}", clrType));
            }
        }
    }
}<commit_msg>Changed default value for unknown setting types<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;

using Hadouken.Configuration;
using Hadouken.Http;
using Hadouken.Reflection;
using Hadouken.Data.Models;

namespace Hadouken.Impl.Http.Api
{
    [ApiAction("getsettings")]
    public class GetSettings : ApiAction
    {
        private IKeyValueStore _data;

        public GetSettings(IKeyValueStore data)
        {
            _data = data;
        }

        public override ActionResult Execute()
        {
            return Json(
                new
                {
                    version = typeof(Kernel).Assembly.GetAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion,
                    settings = (from setting in _data.Get(s => true)
                                select new object[]
                                {
                                    setting.Key,
                                    GetSettingType(setting.Value.GetType()),
                                    setting.Value,
                                    new {
                                        access = -1
                                    }
                                })
                }
            );
        }

        private int GetSettingType(Type clrType)
        {
            switch (clrType.FullName)
            {
                case "System.Int32":
                    return 0;

                case "System.Boolean":
                    return 1;

                case "System.String":
                    return 2;

                default: // unknown (to webui)
                    return -1;
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.07152954481198756, 'fraction_numerical': 0.003958156629912355, 'mean_word_length': 1.0439052570768341, 'pattern_counts': {'":': 6, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1361716', 'n_tokens_mistral': 833, 'n_tokens_neox': 773, 'n_words': 174}