Пример #1
0
        public async Task <VariableStatistics> GetVariableStatistics(string systemName, SessionDetails sessionDetails)
        {
            IFastStatsSystemsApi systemApi = connectorFactory.CreateFastStatsSystemsApi(sessionDetails);
            PagedResultsVariable variables = await systemApi.FastStatsSystemsGetFastStatsVariablesAsync(dataViewName, systemName, null, null, null, 1000000);

            VariableStatistics variableStatistics = new VariableStatistics();

            variableStatistics.SystemName = systemName;

            List <double> numberOfCodesList = new List <double>();
            List <double> totalCodeSizeList = new List <double>();

            foreach (Variable variable in variables.List)
            {
                variableStatistics.NumberOfVariables++;

                if (variable.SelectorInfo != null)
                {
                    int numberOfCodes = variable.SelectorInfo.NumberOfCodes ?? 0;

                    variableStatistics.NumberOfSelectors++;
                    numberOfCodesList.Add(numberOfCodes);
                    totalCodeSizeList.Add(numberOfCodes * variable.SelectorInfo.CodeLength ?? 0);
                }
            }

            variableStatistics.TotalNumberOfVarCodes     = (int)numberOfCodesList.Sum();
            variableStatistics.MedianCodesPerVariable    = DistributionUtilities.GetMedian(numberOfCodesList);
            variableStatistics.TotalCodeSize             = (long)totalCodeSizeList.Sum();
            variableStatistics.MedianCodeSizePerVariable = DistributionUtilities.GetMedian(totalCodeSizeList);
            return(variableStatistics);
        }
Пример #2
0
        public async Task <Variable> GetReferenceVariableForTable(SessionDetails sessionDetails, string systemName, string tableName)
        {
            IFastStatsSystemsApi systemApi = connectorFactory.CreateFastStatsSystemsApi(sessionDetails);

            string filter = $"(TableName eq '{tableName}') and (Type eq 'Reference')";
            PagedResultsVariable variables = await systemApi.FastStatsSystemsGetFastStatsVariablesAsync(dataViewName, systemName, filter, null, null, 1000000);

            if (variables.List.Count == 0)
            {
                return(null);
            }

            return(variables.List[0]);
        }