public async Task <IActionResult> ChangeFailureRate() { 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; ServiceApiClient serviceApiClient = new ServiceApiClient(Configuration); List <ChangeFailureRateModel> items = new List <ChangeFailureRateModel>(); //Get a list of settings List <AzureDevOpsSettings> azureDevOpsSettings = await serviceApiClient.GetAzureDevOpsSettings(); List <GitHubSettings> githubSettings = await serviceApiClient.GetGitHubSettings(); //Create change failure rate models from each Azure DevOps settings object foreach (AzureDevOpsSettings item in azureDevOpsSettings) { ChangeFailureRateModel changeFailureRateModel = await serviceApiClient.GetChangeFailureRate(getSampleData, DevOpsPlatform.AzureDevOps, item.Organization, item.Project, item.Branch, item.BuildName, numberOfDays, maxNumberOfItems); //changeFailureRateModel.ItemOrder = item.ItemOrder; if (changeFailureRateModel != null) { items.Add(changeFailureRateModel); } } //Create change failure rate models from each GitHub settings object foreach (GitHubSettings item in githubSettings) { ChangeFailureRateModel changeFailureRateModel = await serviceApiClient.GetChangeFailureRate(getSampleData, DevOpsPlatform.GitHub, item.Owner, item.Repo, item.Branch, item.WorkflowName, numberOfDays, maxNumberOfItems); //changeFailureRateModel.ItemOrder = item.ItemOrder; if (changeFailureRateModel != null) { items.Add(changeFailureRateModel); } } //sort the final list //items = items.OrderBy(o => o.ItemOrder).ToList(); return(View(items)); }
public async Task <IActionResult> ChangeFailureRate() { int maxNumberOfItems = 20; int numberOfDays = 60; bool getSampleData = false; ServiceApiClient serviceApiClient = new ServiceApiClient(Configuration); List <ChangeFailureRateModel> items = new List <ChangeFailureRateModel>(); //Get a list of settings List <AzureDevOpsSettings> azureDevOpsSettings = await serviceApiClient.GetAzureDevOpsSettings(); List <GitHubSettings> githubSettings = await serviceApiClient.GetGitHubSettings(); //Create MTTR models from each setting object foreach (AzureDevOpsSettings item in azureDevOpsSettings) { ChangeFailureRateModel changeFailureRateModel = await serviceApiClient.GetChangeFailureRate(getSampleData, DevOpsPlatform.AzureDevOps, item.Organization, item.Project, item.Branch, item.BuildName, numberOfDays, maxNumberOfItems); //changeFailureRateModel.ItemOrder = item.ItemOrder; if (changeFailureRateModel != null) { items.Add(changeFailureRateModel); } } foreach (GitHubSettings item in githubSettings) { ChangeFailureRateModel changeFailureRateModel = await serviceApiClient.GetChangeFailureRate(getSampleData, DevOpsPlatform.GitHub, item.Owner, item.Repo, item.Branch, item.WorkflowName, numberOfDays, maxNumberOfItems); //changeFailureRateModel.ItemOrder = item.ItemOrder; if (changeFailureRateModel != null) { items.Add(changeFailureRateModel); } } //sort the list //items = items.OrderBy(o => o.ItemOrder).ToList(); return(View(items)); }
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)); }