Skip to content

Commit

Permalink
Merge pull request #873 from DeveloperMetrics/FixingNullError
Browse files Browse the repository at this point in the history
Fixing null error
  • Loading branch information
samsmithnz authored Jun 8, 2023
2 parents 8d7fef7 + a49d5bf commit 3e852e8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private async static Task<string> GetAzureDevOpsMessage(string url, string patTo
using (HttpResponseMessage response = await client.GetAsync(url))
{
//Throw a response exception
response.EnsureSuccessStatusCode();
//response.EnsureSuccessStatusCode();
if (response.IsSuccessStatusCode)
{
responseBody = await response.Content.ReadAsStringAsync();
Expand Down
11 changes: 7 additions & 4 deletions src/DevOpsMetrics.Core/DataAccess/DORASummaryDA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ public static async Task<DORASummaryItem> GetDORASummaryItem(TableStorageConfigu
{
DORASummaryItem result = null;
List<DORASummaryItem> doraItems = await GetDORASummaryItems(tableStorageConfig, owner);
foreach (DORASummaryItem item in doraItems)
if (doraItems != null)
{
if (item.Repo.ToLower() == repo.ToLower())
foreach (DORASummaryItem item in doraItems)
{
result = item;
break;
if (item.Repo.ToLower() == repo.ToLower())
{
result = item;
break;
}
}
}
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public async Task<JArray> GetTableStorageItemsFromStorage(TableStorageConfigurat
{
TableStorageCommonDA tableDA = new(tableStorageConfig.StorageAccountConnectionString, tableName);
List<AzureStorageTableModel> items = await tableDA.GetItems(partitionKey);
if (items == null)
{
items = new();
}
JArray list = new();
foreach (AzureStorageTableModel item in items)
{
Expand Down Expand Up @@ -109,7 +113,10 @@ public async Task<int> UpdateAzureDevOpsBuildsInStorage(string patToken, TableSt
int numberOfDays, int maxNumberOfItems)
{
JArray items = await AzureDevOpsAPIAccess.GetAzureDevOpsBuildsJArray(patToken, organization, project);

if (items == null)
{
items = new();
}
int itemsAdded = 0;
TableStorageCommonDA tableBuildsDA = new(tableStorageConfig.StorageAccountConnectionString, tableStorageConfig.TableAzureDevOpsBuilds);
TableStorageCommonDA tableChangeFailureRateDA = new(tableStorageConfig.StorageAccountConnectionString, tableStorageConfig.TableChangeFailureRate);
Expand Down Expand Up @@ -154,7 +161,10 @@ public async Task<int> UpdateAzureDevOpsPullRequestsInStorage(string patToken, T
int numberOfDays, int maxNumberOfItems)
{
JArray items = await AzureDevOpsAPIAccess.GetAzureDevOpsPullRequestsJArray(patToken, organization, project, repository);

if (items == null)
{
items = new();
}
int itemsAdded = 0;
TableStorageCommonDA tableDA = new(tableStorageConfig.StorageAccountConnectionString, tableStorageConfig.TableAzureDevOpsPRs);
//Check each build to see if it's in storage, adding the items not in storage
Expand Down Expand Up @@ -183,7 +193,10 @@ public async Task<int> UpdateAzureDevOpsPullRequestCommitsInStorage(string patTo
int numberOfDays, int maxNumberOfItems)
{
JArray items = await AzureDevOpsAPIAccess.GetAzureDevOpsPullRequestCommitsJArray(patToken, organization, project, repository, pullRequestId);

if (items == null)
{
items = new();
}
int itemsAdded = 0;
TableStorageCommonDA tableDA = new(tableStorageConfig.StorageAccountConnectionString, tableStorageConfig.TableAzureDevOpsPRCommits);
//Check each build to see if it's in storage, adding the items not in storage
Expand Down
10 changes: 5 additions & 5 deletions src/DevOpsMetrics.Tests/Service/DORASummaryControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ public async Task DORASummaryControllerGitHubUpdateIntegrationTest()
{
//Arrange
string project = null;
//string organization = "DeveloperMetrics";
//string repository = "DevOpsMetrics";
string organization = "DeveloperMetrics";
string repository = "DevOpsMetrics";
//string organization = "samsmithnz";
//string repository = "AzurePipelinesToGitHubActionsConverter";
string organization = "samsmithnz";
string repository = "GitHubActionsDotNet";
//string repository = "TBS";
//string organization = "samsmithnz";
//string repository = "CustomQueue";
//string organization = "samsmithnz";
//string project = "SamLearnsAzure";
//string repository = "SamLearnsAzure";
Expand Down

0 comments on commit 3e852e8

Please sign in to comment.