Skip to content

Commit

Permalink
Updating dora summary object (#462)
Browse files Browse the repository at this point in the history
* Added project property

* Added another constructor

* Updated constructor

* Supporting project property from Dora Summary object + Azure DevOps
  • Loading branch information
samsmithnz committed Jun 14, 2023
1 parent e456b5e commit 017a60a
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 12 deletions.
11 changes: 10 additions & 1 deletion src/RepoGovernance.Core/Models/DORASummaryItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
//This class will mirror the result from DevOpsMetrics
public class DORASummaryItem
{
public DORASummaryItem(string owner, string repo)
public DORASummaryItem()

Check warning on line 6 in src/RepoGovernance.Core/Models/DORASummaryItem.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Owner' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 6 in src/RepoGovernance.Core/Models/DORASummaryItem.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Project' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 6 in src/RepoGovernance.Core/Models/DORASummaryItem.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'Repo' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 6 in src/RepoGovernance.Core/Models/DORASummaryItem.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'DeploymentFrequencyBadgeURL' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 6 in src/RepoGovernance.Core/Models/DORASummaryItem.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'DeploymentFrequencyBadgeWithMetricURL' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 6 in src/RepoGovernance.Core/Models/DORASummaryItem.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'LeadTimeForChangesBadgeURL' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 6 in src/RepoGovernance.Core/Models/DORASummaryItem.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'LeadTimeForChangesBadgeWithMetricURL' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 6 in src/RepoGovernance.Core/Models/DORASummaryItem.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'MeanTimeToRestoreBadgeURL' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 6 in src/RepoGovernance.Core/Models/DORASummaryItem.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'MeanTimeToRestoreBadgeWithMetricURL' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 6 in src/RepoGovernance.Core/Models/DORASummaryItem.cs

View workflow job for this annotation

GitHub Actions / build

Non-nullable property 'ChangeFailureRateBadgeURL' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 6 in src/RepoGovernance.Core/Models/DORASummaryItem.cs

View workflow job for this annotation

GitHub Actions / test

Non-nullable property 'Owner' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 6 in src/RepoGovernance.Core/Models/DORASummaryItem.cs

View workflow job for this annotation

GitHub Actions / test

Non-nullable property 'Project' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 6 in src/RepoGovernance.Core/Models/DORASummaryItem.cs

View workflow job for this annotation

GitHub Actions / test

Non-nullable property 'Repo' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 6 in src/RepoGovernance.Core/Models/DORASummaryItem.cs

View workflow job for this annotation

GitHub Actions / test

Non-nullable property 'DeploymentFrequencyBadgeURL' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 6 in src/RepoGovernance.Core/Models/DORASummaryItem.cs

View workflow job for this annotation

GitHub Actions / test

Non-nullable property 'DeploymentFrequencyBadgeWithMetricURL' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 6 in src/RepoGovernance.Core/Models/DORASummaryItem.cs

View workflow job for this annotation

GitHub Actions / test

Non-nullable property 'LeadTimeForChangesBadgeURL' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 6 in src/RepoGovernance.Core/Models/DORASummaryItem.cs

View workflow job for this annotation

GitHub Actions / test

Non-nullable property 'LeadTimeForChangesBadgeWithMetricURL' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 6 in src/RepoGovernance.Core/Models/DORASummaryItem.cs

View workflow job for this annotation

GitHub Actions / test

Non-nullable property 'MeanTimeToRestoreBadgeURL' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 6 in src/RepoGovernance.Core/Models/DORASummaryItem.cs

View workflow job for this annotation

GitHub Actions / Run SonarCloud analysis

Non-nullable property 'Owner' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 6 in src/RepoGovernance.Core/Models/DORASummaryItem.cs

View workflow job for this annotation

GitHub Actions / Run SonarCloud analysis

Non-nullable property 'Project' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 6 in src/RepoGovernance.Core/Models/DORASummaryItem.cs

View workflow job for this annotation

GitHub Actions / Run SonarCloud analysis

Non-nullable property 'Repo' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 6 in src/RepoGovernance.Core/Models/DORASummaryItem.cs

View workflow job for this annotation

GitHub Actions / Run SonarCloud analysis

Non-nullable property 'DeploymentFrequencyBadgeURL' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 6 in src/RepoGovernance.Core/Models/DORASummaryItem.cs

View workflow job for this annotation

GitHub Actions / Run SonarCloud analysis

Non-nullable property 'DeploymentFrequencyBadgeWithMetricURL' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 6 in src/RepoGovernance.Core/Models/DORASummaryItem.cs

View workflow job for this annotation

GitHub Actions / Run SonarCloud analysis

Non-nullable property 'LeadTimeForChangesBadgeURL' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 6 in src/RepoGovernance.Core/Models/DORASummaryItem.cs

View workflow job for this annotation

GitHub Actions / Run SonarCloud analysis

Non-nullable property 'LeadTimeForChangesBadgeWithMetricURL' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Check warning on line 6 in src/RepoGovernance.Core/Models/DORASummaryItem.cs

View workflow job for this annotation

GitHub Actions / Run SonarCloud analysis

Non-nullable property 'MeanTimeToRestoreBadgeURL' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
{
}

public DORASummaryItem(string owner, string project, string repo)
{
Owner = owner;
Project = project;
Repo = repo;
//Set the properties to defaults (none)
DeploymentFrequency = 0;
Expand All @@ -27,6 +32,10 @@ public string Owner
{
get; set;
}
public string Project
{
get; set;
}
public string Repo
{
get; set;
Expand Down
2 changes: 1 addition & 1 deletion src/RepoGovernance.Core/Models/ProfileOwnerRepo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
public class UserOwnerRepo
{
public UserOwnerRepo(string user, string owner, string repo)
public UserOwnerRepo(string user, string owner, string repo)
{
User = user;
Owner = owner;
Expand Down
13 changes: 7 additions & 6 deletions src/RepoGovernance.Core/SummaryItemsDA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public static List<UserOwnerRepo> GetRepos(string user)
string? devOpsServiceURL,
string user,
string owner,
string project,
string repo)
{
int itemsUpdated = 0;
Expand Down Expand Up @@ -215,15 +216,15 @@ public static List<UserOwnerRepo> GetRepos(string user)
Branch = "main"
};
List<FrameworkSummary> frameworkSummaries = DotNetCensus.Core.Main.GetFrameworkSummary(null, repo2, false);
foreach (FrameworkSummary project in frameworkSummaries)
foreach (FrameworkSummary frameworkSummary in frameworkSummaries)
{
Framework framework = new()
{
Name = project.Framework,
Color = DotNetRepoScanner.GetColorFromStatus(project.Status)
Name = frameworkSummary.Framework,
Color = DotNetRepoScanner.GetColorFromStatus(frameworkSummary.Status)
};
if (project.Framework != null &&
summaryItem?.DotNetFrameworks.Where(p => p.Name == project.Framework).FirstOrDefault() == null)
if (frameworkSummary.Framework != null &&
summaryItem?.DotNetFrameworks.Where(p => p.Name == frameworkSummary.Framework).FirstOrDefault() == null)
{
summaryItem?.DotNetFrameworks.Add(framework);
}
Expand Down Expand Up @@ -284,7 +285,7 @@ public static List<UserOwnerRepo> GetRepos(string user)
else
{
//Initialize an empty DORA summary item
dORASummaryItem = new(owner, repo)
dORASummaryItem = new(owner, project, repo)
{
DeploymentFrequency = 0,
LeadTimeForChanges = 0,
Expand Down
3 changes: 2 additions & 1 deletion src/RepoGovernance.Function/ProcessItemFromQueueFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public static async Task Run([QueueTrigger("summaryqueue", Connection = "AzureWe
string[] parts = myQueueItem.Split('_');
string user = "";
string owner = "";
string project = "";
string repo = "";
if (parts.Length == 2)
{
Expand Down Expand Up @@ -51,7 +52,7 @@ public static async Task Run([QueueTrigger("summaryqueue", Connection = "AzureWe
Configuration["GitHubClientSecret"],
Configuration["SummaryQueueConnection"],
Configuration["DevOpsServiceURL"],
user, owner, repo);
user, owner, project, repo);
if (itemsUpdated > 0)
{
log.LogInformation($"C# Queue trigger function completed updating {itemsUpdated} items at: {DateTime.Now}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ public List<UserOwnerRepo> GetRepos(string owner)
/// <param name="repo">the repository being updated</param>
/// <returns></returns>
[HttpGet("UpdateSummaryItem")]
public async Task<int> UpdateSummaryItem(string user, string owner, string repo)
public async Task<int> UpdateSummaryItem(string user, string owner,string project, string repo)
{
return await SummaryItemsDA.UpdateSummaryItem(
Configuration["AppSettings:GitHubClientId"],
Configuration["AppSettings:GitHubClientSecret"],
Configuration["AppSettings:CosmosDBConnectionString"],//Configuration["AppSettings:StorageConnectionString"],
Configuration["AppSettings:DevOpsServiceURL"],
user, owner, repo);
user, owner, project, repo);
}

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion src/RepoGovernance.Tests/SummaryItemsControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ public async Task UpdateRepoGovernanceSummaryItemTest()
//Arrange
string user = "samsmithnz";
string owner = "samsmithnz";
string project = null;
string repo = "CustomQueue";

//Act - runs a repo in about 4s
int itemsUpdated = await SummaryItemsDA.UpdateSummaryItem(GitHubId, GitHubSecret, AzureStorageConnectionString, DevOpsServiceURL, user, owner, repo);
int itemsUpdated = await SummaryItemsDA.UpdateSummaryItem(GitHubId, GitHubSecret, AzureStorageConnectionString, DevOpsServiceURL, user, owner, project, repo);

//Assert
Assert.AreEqual(1, itemsUpdated);
Expand Down

0 comments on commit 017a60a

Please sign in to comment.