Exemplo n.º 1
0
        public async Task <IActionResult> LeadTimeForChanges()
        {
            int              maxNumberOfItems    = 20;   //20 is the optimium max that looks good with the current UI
            int              numberOfDays        = 30;   //TODO: Move number of days variable to a drop down list on the current UI
            bool             getSampleData       = false;
            bool             useCache            = true; //Use Azure storage instead of hitting the API. Quicker, but data may be up to 4 hours out of date
            string           patToken            = Configuration["AppSettings:AzureDevOpsPatToken"];
            string           clientId            = Configuration["AppSettings:GitHubClientId"];
            string           clientSecret        = Configuration["AppSettings:GitHubClientSecret"];
            ServiceApiClient serviceApiClient    = new ServiceApiClient(Configuration);
            List <LeadTimeForChangesModel> items = new List <LeadTimeForChangesModel>();

            //Get a list of settings
            List <AzureDevOpsSettings> azureDevOpsSettings = await serviceApiClient.GetAzureDevOpsSettings();

            List <GitHubSettings> githubSettings = await serviceApiClient.GetGitHubSettings();

            //Create lead time for changes models from each Azure DevOps setting object
            foreach (AzureDevOpsSettings item in azureDevOpsSettings)
            {
                LeadTimeForChangesModel newLeadTimeForChangesModel = await serviceApiClient.GetAzureDevOpsLeadTimeForChanges(getSampleData, patToken,
                                                                                                                             item.Organization, item.Project, item.Repository, item.Branch, item.BuildName, item.BuildId,
                                                                                                                             numberOfDays, maxNumberOfItems, useCache);

                newLeadTimeForChangesModel.ItemOrder = item.ItemOrder;
                if (newLeadTimeForChangesModel != null)
                {
                    items.Add(newLeadTimeForChangesModel);
                }
            }
            //Create lead time for changes models from each GitHub setting object
            foreach (GitHubSettings item in githubSettings)
            {
                LeadTimeForChangesModel newLeadTimeForChangesModel = await serviceApiClient.GetGitHubLeadTimeForChanges(getSampleData, clientId, clientSecret,
                                                                                                                        item.Owner, item.Repo, item.Branch, item.WorkflowName, item.WorkflowId,
                                                                                                                        numberOfDays, maxNumberOfItems, useCache);

                newLeadTimeForChangesModel.ItemOrder = item.ItemOrder;
                if (newLeadTimeForChangesModel != null)
                {
                    items.Add(newLeadTimeForChangesModel);
                }
            }

            //sort the final list
            items = items.OrderBy(o => o.ItemOrder).ToList();
            return(View(items));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> LeadTimeForChanges()
        {
            string           patToken            = Configuration["AppSettings:AzureDevOpsPatToken"];
            string           clientId            = Configuration["AppSettings:GitHubClientId"];
            string           clientSecret        = Configuration["AppSettings:GitHubClientSecret"];
            int              maxNumberOfItems    = 20;
            int              numberOfDays        = 60;
            bool             getSampleData       = false;
            bool             useCache            = true;
            ServiceApiClient serviceApiClient    = new ServiceApiClient(Configuration);
            List <LeadTimeForChangesModel> items = new List <LeadTimeForChangesModel>();

            //Get a list of settings
            List <AzureDevOpsSettings> azureDevOpsSettings = await serviceApiClient.GetAzureDevOpsSettings();

            List <GitHubSettings> githubSettings = await serviceApiClient.GetGitHubSettings();

            //Create deployment frequency models from each setting object
            foreach (AzureDevOpsSettings item in azureDevOpsSettings)
            {
                LeadTimeForChangesModel newLeadTimeForChangesModel = await serviceApiClient.GetAzureDevOpsLeadTimeForChanges(getSampleData, patToken,
                                                                                                                             item.Organization, item.Project, item.Repository, item.Branch, item.BuildName, item.BuildId,
                                                                                                                             numberOfDays, maxNumberOfItems, useCache);

                newLeadTimeForChangesModel.ItemOrder = item.ItemOrder;
                if (newLeadTimeForChangesModel != null)
                {
                    items.Add(newLeadTimeForChangesModel);
                }
            }
            foreach (GitHubSettings item in githubSettings)
            {
                LeadTimeForChangesModel newLeadTimeForChangesModel = await serviceApiClient.GetGitHubLeadTimeForChanges(getSampleData, clientId, clientSecret,
                                                                                                                        item.Owner, item.Repo, item.Branch, item.WorkflowName, item.WorkflowId,
                                                                                                                        numberOfDays, maxNumberOfItems, useCache);

                newLeadTimeForChangesModel.ItemOrder = item.ItemOrder;
                if (newLeadTimeForChangesModel != null)
                {
                    items.Add(newLeadTimeForChangesModel);
                }
            }

            //sort the list
            items = items.OrderBy(o => o.ItemOrder).ToList();
            return(View(items));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Project(string rowKey, int numberOfDays = 30)
        {
            int              maxNumberOfItems = 20;
            bool             getSampleData    = false;
            bool             useCache         = true;
            string           patToken         = Configuration["AppSettings:AzureDevOpsPatToken"];
            string           clientId         = Configuration["AppSettings:GitHubClientId"];
            string           clientSecret     = Configuration["AppSettings:GitHubClientSecret"];
            ProjectViewModel model            = new ProjectViewModel();

            //Find the right project to load
            ServiceApiClient           serviceApiClient    = new ServiceApiClient(Configuration);
            List <AzureDevOpsSettings> azureDevOpsSettings = await serviceApiClient.GetAzureDevOpsSettings();

            List <GitHubSettings> githubSettings = await serviceApiClient.GetGitHubSettings();

            //Create the days to view dropdown
            List <NumberOfDaysItem> numberOfDaysList = new List <NumberOfDaysItem>
            {
                new NumberOfDaysItem {
                    NumberOfDays = 7
                },
                new NumberOfDaysItem {
                    NumberOfDays = 14
                },
                new NumberOfDaysItem {
                    NumberOfDays = 21
                },
                new NumberOfDaysItem {
                    NumberOfDays = 30
                },
                new NumberOfDaysItem {
                    NumberOfDays = 60
                },
                new NumberOfDaysItem {
                    NumberOfDays = 90
                }
            };

            //Get Azure DevOps project details
            AzureDevOpsSettings azureDevOpsSetting;

            foreach (AzureDevOpsSettings item in azureDevOpsSettings)
            {
                if (item.RowKey == rowKey)
                {
                    azureDevOpsSetting = item;

                    DeploymentFrequencyModel deploymentFrequencyModel = await serviceApiClient.GetAzureDevOpsDeploymentFrequency(getSampleData, patToken,
                                                                                                                                 item.Organization, item.Project, item.Branch, item.BuildName, item.BuildId,
                                                                                                                                 numberOfDays, maxNumberOfItems, useCache);

                    LeadTimeForChangesModel leadTimeForChangesModel = await serviceApiClient.GetAzureDevOpsLeadTimeForChanges(getSampleData, patToken,
                                                                                                                              item.Organization, item.Project, item.Repository, item.Branch, item.BuildName, item.BuildId,
                                                                                                                              numberOfDays, maxNumberOfItems, useCache);

                    MeanTimeToRestoreModel meanTimeToRestoreModel = await serviceApiClient.GetAzureMeanTimeToRestore(getSampleData,
                                                                                                                     DevOpsPlatform.AzureDevOps, item.ProductionResourceGroup, numberOfDays, maxNumberOfItems);

                    ChangeFailureRateModel changeFailureRateModel = await serviceApiClient.GetChangeFailureRate(getSampleData,
                                                                                                                DevOpsPlatform.AzureDevOps, item.Organization, item.Project, item.Branch, item.BuildName,
                                                                                                                numberOfDays, maxNumberOfItems);

                    deploymentFrequencyModel.IsProjectView = true;
                    leadTimeForChangesModel.IsProjectView  = true;
                    meanTimeToRestoreModel.IsProjectView   = true;
                    changeFailureRateModel.IsProjectView   = true;
                    model = new ProjectViewModel
                    {
                        RowKey               = item.RowKey,
                        ProjectName          = item.Project,
                        TargetDevOpsPlatform = DevOpsPlatform.AzureDevOps,
                        DeploymentFrequency  = deploymentFrequencyModel,
                        LeadTimeForChanges   = leadTimeForChangesModel,
                        MeanTimeToRestore    = meanTimeToRestoreModel,
                        ChangeFailureRate    = changeFailureRateModel,
                        NumberOfDays         = new SelectList(numberOfDaysList, "NumberOfDays", "NumberOfDays"),
                        NumberOfDaysSelected = numberOfDays
                    };
                }
            }
            //Get GitHub project details
            GitHubSettings githubSetting;

            foreach (GitHubSettings item in githubSettings)
            {
                if (item.RowKey == rowKey)
                {
                    githubSetting = item;

                    DeploymentFrequencyModel deploymentFrequencyModel = await serviceApiClient.GetGitHubDeploymentFrequency(getSampleData, clientId, clientSecret,
                                                                                                                            item.Owner, item.Repo, item.Branch, item.WorkflowName, item.WorkflowId,
                                                                                                                            numberOfDays, maxNumberOfItems, useCache);

                    LeadTimeForChangesModel leadTimeForChangesModel = await serviceApiClient.GetGitHubLeadTimeForChanges(getSampleData, clientId, clientSecret,
                                                                                                                         item.Owner, item.Repo, item.Branch, item.WorkflowName, item.WorkflowId,
                                                                                                                         numberOfDays, maxNumberOfItems, useCache);

                    MeanTimeToRestoreModel meanTimeToRestoreModel = await serviceApiClient.GetAzureMeanTimeToRestore(getSampleData,
                                                                                                                     DevOpsPlatform.GitHub, item.ProductionResourceGroup, numberOfDays, maxNumberOfItems);

                    ChangeFailureRateModel changeFailureRateModel = await serviceApiClient.GetChangeFailureRate(getSampleData,
                                                                                                                DevOpsPlatform.GitHub, item.Owner, item.Repo, item.Branch, item.WorkflowName,
                                                                                                                numberOfDays, maxNumberOfItems);

                    deploymentFrequencyModel.IsProjectView = true;
                    leadTimeForChangesModel.IsProjectView  = true;
                    meanTimeToRestoreModel.IsProjectView   = true;
                    changeFailureRateModel.IsProjectView   = true;
                    model = new ProjectViewModel
                    {
                        RowKey               = item.RowKey,
                        ProjectName          = item.Repo,
                        TargetDevOpsPlatform = DevOpsPlatform.GitHub,
                        DeploymentFrequency  = deploymentFrequencyModel,
                        LeadTimeForChanges   = leadTimeForChangesModel,
                        MeanTimeToRestore    = meanTimeToRestoreModel,
                        ChangeFailureRate    = changeFailureRateModel,
                        NumberOfDays         = new SelectList(numberOfDaysList, "NumberOfDays", "NumberOfDays"),
                        NumberOfDaysSelected = numberOfDays
                    };
                }
            }

            return(View(model));
        }