<commit_before>﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using System.Web.Mvc;
using Derivco.Orniscient.Proxy.Grains;
using Derivco.Orniscient.Proxy.Grains.Filters;
using Derivco.Orniscient.Proxy.Grains.Models;
using Derivco.Orniscient.Viewer.Models.Dashboard;
using Derivco.Orniscient.Viewer.Observers;
using Orleans;

namespace Derivco.Orniscient.Viewer.Controllers
{
    public class DashboardController : Controller
    {
        // GET: Dashboard
        public async Task<ActionResult> Index(int id = 0)
        {
            try
            {
                if (!GrainClient.IsInitialized)
                {
                    GrainClient.Initialize(Server.MapPath("~/DevTestClientConfiguration.xml"));
                    await OrniscientObserver.Instance.SetTypeFilter(p => p.FullName.Contains(ConfigurationManager.AppSettings["GlobalFilter"]));
                }
                return View();
            }
            catch (Exception)
            {
                return View("InitError");
            }
        }

        public async Task<ActionResult> GetDashboardInfo()
        {
            var dashboardCollectorGrain = GrainClient.GrainFactory.GetGrain<IDashboardCollectorGrain>(Guid.Empty);

            var types = await dashboardCollectorGrain.GetGrainTypes();
            var dashboardInfo = new DashboardInfo
            {
                Silos = await dashboardCollectorGrain.GetSilos(),
                AvailableTypes = types
            };

            return Json(dashboardInfo, JsonRequestBehavior.AllowGet);
        }

        public async Task<ActionResult> GetFilters(GetFiltersRequest filtersRequest)
        {
            if (filtersRequest?.Types == null)
                return null;
<commit_msg>Fixed issue where Orniscient.Viewer is hanging. Ref : https://github.com/dotnet/orleans/issues/146#issuecomment-75093984<commit_after>﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using System.Web.Mvc;
using Derivco.Orniscient.Proxy.Grains;
using Derivco.Orniscient.Proxy.Grains.Filters;
using Derivco.Orniscient.Proxy.Grains.Models;
using Derivco.Orniscient.Viewer.Models.Dashboard;
using Derivco.Orniscient.Viewer.Observers;
using Orleans;

namespace Derivco.Orniscient.Viewer.Controllers
{
    public class DashboardController : Controller
    {
        // GET: Dashboard
        public async Task<ActionResult> Index(int id = 0)
        {
            try
            {
                if (!GrainClient.IsInitialized)
                {
                    var path = Server.MapPath("~/DevTestClientConfiguration.xml");
                    Task.Run(() =>
                    {
                        GrainClient.Initialize(path);
                    }).Wait();

                    await OrniscientObserver.Instance.SetTypeFilter(p => p.FullName.Contains(ConfigurationManager.AppSettings["GlobalFilter"]));
                }
                return View();
            }
            catch (Exception)
            {
                return View("InitError");
            }
        }

        public async Task<ActionResult> GetDashboardInfo()
        {
            var dashboardCollectorGrain = GrainClient.GrainFactory.GetGrain<IDashboardCollectorGrain>(Guid.Empty);

            var types = await dashboardCollectorGrain.GetGrainTypes();
            var dashboardInfo = new DashboardInfo
            {
                Silos = await dashboardCollectorGrain.GetSilos(),
                AvailableTypes = types
            };

            return Json(dashboardInfo, JsonRequestBehavior.AllowGet);
        }

        public async Task<ActionResult> GetFilters(GetFiltersRequest filtersRequest)
        {
            if (filtersRequest?.Types == null)
                return null;

{'fraction_non_alphanumeric': 0.08637873754152824, 'fraction_numerical': 0.0033222591362126247, 'mean_word_length': 2.126198083067093, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 14, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '4157031', 'n_tokens_mistral': 1055, 'n_tokens_neox': 1033, 'n_words': 184}