public IActionResult GetOverviewStats(StatsOverviewRequest request)
        {
            StatsOverviewResponse result = new StatsOverviewResponse();

            if (request != null && request.Filter != null)
            {
                HandleException(() =>
                {
                    var data     = new StatsOverviewData();
                    int topCount = 10;
                    var totalRelationStatsRepository = DALRepositories.GetTotalRelationStatisticsRepository();
                    var statementStatsRepository     = DALRepositories.GetNormalizedStatementStatisticsRepository();
                    // alive relations
                    var summaryTotalRelationStatistics = totalRelationStatsRepository.GetSummaryTotalRelationStatistics(request.DatabaseID, request.Filter.DateFrom, request.Filter.DateTo, topCount);
                    data.MostAliveRelations            = Converter.ConvertToMostAliveRelations(summaryTotalRelationStatistics);
                    // top executed
                    var topExecuted             = statementStatsRepository.GetSummaryTotalStatementStatistics(request.DatabaseID, request.Filter.DateFrom, request.Filter.DateTo, DAL.Contracts.SummaryNormalizedStatementStatisticsOrderBy.ExecutionCount, null, topCount);
                    data.MostExecutedStatements = Converter.ConvertToMostExecutedStatements(topExecuted);
                    // slowest
                    var topSlowest             = statementStatsRepository.GetSummaryTotalStatementStatistics(request.DatabaseID, request.Filter.DateFrom, request.Filter.DateTo, DAL.Contracts.SummaryNormalizedStatementStatisticsOrderBy.MaxDuration, null, topCount);
                    data.MostSlowestStatements = Converter.ConvertToMostSlowestStatements(topSlowest);
                    result.Data      = data;
                    result.IsSuccess = data != null;
                }, ex => result.ErrorMessage = ex.Message);
            }
            return(Json(result));
        }
        public IActionResult GetStatementsStatistics(GetStatementsStatisticsRequest request)
        {
            GetStatementsStatisticsResponse result = new GetStatementsStatisticsResponse();

            if (request != null && request.Filter != null)
            {
                HandleException(() =>
                {
                    var data = new StatementsStatisticsData();
                    var normalizedStatementStatisticsRepository = DALRepositories.GetNormalizedStatementStatisticsRepository();
                    data.SummaryNormalizedStatementStatistics   = normalizedStatementStatisticsRepository.GetSummaryTotalStatementStatistics(request.DatabaseID,
                                                                                                                                             request.Filter.DateFrom, request.Filter.DateTo, DAL.Contracts.SummaryNormalizedStatementStatisticsOrderBy.MaxDuration,
                                                                                                                                             Converter.CreateCommandTypeFilter(request.Filter.CommandType), null).ToList();
                    result.Data      = data;
                    result.IsSuccess = result.Data != null;
                }, ex => result.ErrorMessage = ex.Message);
            }
            return(Json(result));
        }
        public IActionResult GetStatementStatistics(GetStatementStatisticsRequest request)
        {
            GetStatementStatisticsResponse result = new GetStatementStatisticsResponse();

            if (request != null && request.Filter != null)
            {
                HandleException(() =>
                {
                    var data = new StatementStatisticsData();
                    var totalStatsRepository         = DALRepositories.GetNormalizedStatementStatisticsRepository();
                    var relationStatsRepository      = DALRepositories.GetNormalizedStatementRelationStatisticsRepository();
                    var indexStatsRepository         = DALRepositories.GetNormalizedStatementIndexStatisticsRepository();
                    data.StatementTimeline           = totalStatsRepository.GetTimelineForStatement(request.StatementID, request.Filter.DateFrom, request.Filter.DateTo).ToList();
                    data.StatementRelationStatistics = relationStatsRepository.GetAllForStatement(request.StatementID, request.Filter.DateFrom, request.Filter.DateTo).ToList();
                    data.StatementIndexStatistics    = indexStatsRepository.GetAllForStatement(request.StatementID, request.Filter.DateFrom, request.Filter.DateTo).ToList();
                    data.SlowestRepresentatives      = totalStatsRepository.GetSlowestForStatement(request.StatementID, request.Filter.DateFrom, request.Filter.DateTo, 10).ToList();
                    result.Data      = data;
                    result.IsSuccess = result.Data != null;
                }, ex => result.ErrorMessage = ex.Message);
            }
            return(Json(result));
        }