Skip to content

Commit

Permalink
Merge pull request #881 from DeveloperMetrics/FixToServiceCall
Browse files Browse the repository at this point in the history
Fix to service call
  • Loading branch information
samsmithnz authored Jun 21, 2023
2 parents 7694ffb + 5664273 commit 2468dda
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 41 deletions.
6 changes: 3 additions & 3 deletions src/DevOpsMetrics.Cmd/ServiceApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public async Task<List<GitHubSettings>> GetGitHubSettings()
}

public async Task<ProcessingResult> UpdateDORASummaryItem(
string owner, string project, string repository,
string branch, string workflowName, string workflowId,
string resourceGroup, int numberOfDays, int maxNumberOfItems,
string owner, string project, string repository,
string branch, string workflowName, string workflowId,
string resourceGroup, int numberOfDays, int maxNumberOfItems,
bool isGitHub = true)
{
string url = $"/api/DORASummary/UpdateDORASummaryItem?owner={owner}&project={project}&repository={repository}&branch={branch}&workflowName={workflowName}&workflowId={workflowId}&resourceGroup={resourceGroup}&numberOfDays={numberOfDays}&maxNumberOfItems={maxNumberOfItems}&log=&useCache=true&isGitHub={isGitHub}";
Expand Down
2 changes: 1 addition & 1 deletion src/DevOpsMetrics.Core/DataAccess/DORASummaryDA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static async Task<DORASummaryItem> GetDORASummaryItem(TableStorageConfigu
{
foreach (DORASummaryItem item in doraItems)
{
if ((project != null && item.Project == project) || (item.Repo.ToLower() == repo.ToLower()))
if ((project != null && item.Project == project) || (item.Repo?.ToLower() == repo.ToLower()))
{
result = item;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,23 +116,26 @@ public async Task<bool> SaveItem(AzureStorageTableModel data)

public static string EncodePartitionKey(string text)
{
//The forward slash(/) character
//The backslash(\) character
//The number sign(#) character
//The question mark (?) character
text = text.Replace("/", "_");
//text = text.Replace("\\", "_");
//text = text.Replace("#", "_");
//text = text.Replace("?", "_");

////Control characters from U+0000 to U+001F, including:
////The horizontal tab(\t) character
//text = text.Replace("\t", "_");
////The linefeed(\n) character
//text = text.Replace("\n", "_");
////The carriage return (\r) character
//text = text.Replace("\r", "_");
////Control characters from U + 007F to U+009F
if (string.IsNullOrEmpty(text) == false)
{
//The forward slash(/) character
//The backslash(\) character
//The number sign(#) character
//The question mark (?) character
text = text.Replace("/", "_");
//text = text.Replace("\\", "_");
//text = text.Replace("#", "_");
//text = text.Replace("?", "_");

////Control characters from U+0000 to U+001F, including:
////The horizontal tab(\t) character
//text = text.Replace("\t", "_");
////The linefeed(\n) character
//text = text.Replace("\n", "_");
////The carriage return (\r) character
//text = text.Replace("\r", "_");
////Control characters from U + 007F to U+009F
}

return text;
}
Expand Down
1 change: 0 additions & 1 deletion src/DevOpsMetrics.Function/AzureAlertProcessor.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
using DevOpsMetrics.Core.DataAccess.TableStorage;
using DevOpsMetrics.Core.Models.Common;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
Expand Down
2 changes: 1 addition & 1 deletion src/DevOpsMetrics.Function/NightlyProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static async Task Run(
{
log.LogInformation($"Processing Azure DevOps organization {azSetting.Organization}, project {azSetting.Project}");
ProcessingResult ghResult = await serviceApiClient.UpdateDORASummaryItem(
azSetting.Organization, azSetting.Project, azSetting.Repository,
azSetting.Organization, azSetting.Project, azSetting.Repository,
azSetting.Branch, azSetting.BuildName, azSetting.BuildId,
azSetting.ProductionResourceGroup,
numberOfDays, maxNumberOfItems, false);
Expand Down
7 changes: 3 additions & 4 deletions src/DevOpsMetrics.Function/ServiceApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using DevOpsMetrics.Core.Models.Common;
using DevOpsMetrics.Core.Models.GitHub;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;

namespace DevOpsMetrics.Function
Expand Down Expand Up @@ -40,9 +39,9 @@ public async Task<List<GitHubSettings>> GetGitHubSettings()
}

public async Task<ProcessingResult> UpdateDORASummaryItem(
string owner, string project, string repository,
string branch, string workflowName, string workflowId,
string resourceGroup, int numberOfDays, int maxNumberOfItems,
string owner, string project, string repository,
string branch, string workflowName, string workflowId,
string resourceGroup, int numberOfDays, int maxNumberOfItems,
bool isGitHub = true)
{
string url = $"/api/DORASummary/UpdateDORASummaryItem?owner={owner}&project={project}&repository={repository}&branch={branch}&workflowName={workflowName}&workflowId={workflowId}&resourceGroup={resourceGroup}&numberOfDays={numberOfDays}&maxNumberOfItems={maxNumberOfItems}&log=&useCache=true&isGitHub={isGitHub}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
using DevOpsMetrics.Core.DataAccess.TableStorage;
using DevOpsMetrics.Core.Models.Common;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Build.Framework;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;

namespace DevOpsMetrics.Service.Controllers
{
Expand Down Expand Up @@ -56,7 +54,7 @@ public async Task<ProcessingResult> UpdateDORASummaryItem(
Microsoft.Extensions.Logging.ILogger log = null,
bool useCache = true,
bool isGitHub = true,
bool useParallelProcessing = false)
bool useParallelProcessing = true)
{
//Start timer
DateTime startTime = DateTime.Now;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public async Task<bool> UpdateAzureDevOpsProjectLog(string organization, string
}

[HttpGet("GetGitHubProjectLog")]
public async Task< List<ProjectLog>> GetGitHubProjectLog(string owner, string repo)
public async Task<List<ProjectLog>> GetGitHubProjectLog(string owner, string repo)
{
string partitionKey = PartitionKeys.CreateGitHubSettingsPartitionKey(owner, repo);

Expand Down
10 changes: 4 additions & 6 deletions src/DevOpsMetrics.Tests/Service/DORASummaryControllerTests.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Threading.Tasks;
using DevOpsMetrics.Core.DataAccess.TableStorage;
using DevOpsMetrics.Core.Models.AzureDevOps;
using DevOpsMetrics.Core.Models.Common;
using DevOpsMetrics.Core.Models.GitHub;
using DevOpsMetrics.Service.Controllers;
using Microsoft.AspNetCore.Mvc;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace DevOpsMetrics.Tests.Service
Expand Down Expand Up @@ -40,10 +38,10 @@ public async Task DORASummaryControllerGitHubUpdateIntegrationTest()
{
//Arrange
string project = null;
string organization = "DeveloperMetrics";
string repo = "DevOpsMetrics";
//string organization = "samsmithnz";
//string repo = "Sams2048";
//string organization = "DeveloperMetrics";
//string repo = "DevOpsMetrics";
string organization = "samsmithnz";
string repo = "SamsFeatureFlags";
//string organization = "samsmithnz";
//string repo = "CustomQueue";
//string organization = "samsmithnz";
Expand Down
2 changes: 1 addition & 1 deletion src/DevOpsMetrics.Tests/Service/TableStorageDATests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public async Task AzGetPRCommitsDAIntegrationTest()
{
AzureDevOpsPR pullRequest = JsonConvert.DeserializeObject<AzureDevOpsPR>(item.ToString());
string pullRequestId = pullRequest.PullRequestId;
JArray list =await da.GetTableStorageItemsFromStorage(tableStorageConfig, tableStorageConfig.TableAzureDevOpsPRCommits, PartitionKeys.CreateAzureDevOpsPRCommitPartitionKey(organization, project, pullRequestId));
JArray list = await da.GetTableStorageItemsFromStorage(tableStorageConfig, tableStorageConfig.TableAzureDevOpsPRCommits, PartitionKeys.CreateAzureDevOpsPRCommitPartitionKey(organization, project, pullRequestId));
if (list.Count > 0)
{
itemsAdded = list.Count;
Expand Down
3 changes: 0 additions & 3 deletions src/DevOpsMetrics.Web/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@
using DevOpsMetrics.Core.Models.AzureDevOps;
using DevOpsMetrics.Core.Models.Common;
using DevOpsMetrics.Core.Models.GitHub;
using DevOpsMetrics.Service.Controllers;
using DevOpsMetrics.Web.Models;
using DevOpsMetrics.Web.Services;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.CodeAnalysis;
using Microsoft.Extensions.Configuration;
using NuGet.Protocol;

namespace DevOpsMetrics.Web.Controllers
{
Expand Down

0 comments on commit 2468dda

Please sign in to comment.