-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from samsmithnz/AddingAggregations
Added new aggregations
- Loading branch information
Showing
19 changed files
with
441 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
using DotNetCensus.Core.Models; | ||
|
||
namespace DotNetCensus.Core | ||
{ | ||
public static class Census | ||
{ | ||
public static List<FrameworkSummary> AggregateFrameworks(List<Project> projects, bool includeTotal) | ||
{ | ||
int total = 0; | ||
List<FrameworkSummary> frameworkSummary = new(); | ||
foreach (Project project in projects) | ||
{ | ||
project.Family = DotNetProjectScanning.GetFrameworkFamily(project.Framework); | ||
if (string.IsNullOrEmpty(project.Framework) == true) | ||
{ | ||
project.Framework = "(Unknown framework)"; | ||
} | ||
|
||
//Process each indvidual framework | ||
FrameworkSummary? framework = frameworkSummary.Find(i => i.Framework == project.Framework); | ||
|
||
//If this framework isn't in the current list, create a new one | ||
if (framework == null) | ||
{ | ||
frameworkSummary.Add(new FrameworkSummary | ||
{ | ||
Framework = project.Framework, | ||
FrameworkFamily = project.Family, | ||
Count = 1 //it's the first time, start with a count of 1 | ||
}); | ||
} | ||
else | ||
{ | ||
//There is an existing entry, increment the count | ||
framework.Count++; | ||
} | ||
total++; | ||
} | ||
|
||
//Sort the result | ||
List<FrameworkSummary> sortedFrameworks = frameworkSummary.OrderBy(o => o.Framework).ToList(); | ||
|
||
//Add a total line if we need one | ||
if (includeTotal == true) | ||
{ | ||
sortedFrameworks.Add(new FrameworkSummary { Framework = "total frameworks", Count = total }); | ||
} | ||
return sortedFrameworks; | ||
} | ||
|
||
public static List<LanguageSummary> AggregateLanguages(List<Project> projects, bool includeTotal) | ||
{ | ||
int total = 0; | ||
List<LanguageSummary> languageSummary = new(); | ||
foreach (Project project in projects) | ||
{ | ||
if (string.IsNullOrEmpty(project.Language) == true) | ||
{ | ||
project.Language = "(Unknown language)"; | ||
} | ||
|
||
//Process each indvidual language | ||
LanguageSummary? language = languageSummary.Find(i => i.Language == project.Language); | ||
|
||
//If this language isn't in the current list, create a new one | ||
if (language == null) | ||
{ | ||
languageSummary.Add(new LanguageSummary | ||
{ | ||
Language = project.Language, | ||
Count = 1 //it's the first time, start with a count of 1 | ||
}); | ||
} | ||
else | ||
{ | ||
//There is an existing entry, increment the count | ||
language.Count++; | ||
} | ||
total++; | ||
} | ||
|
||
//Sort the result | ||
List<LanguageSummary> sortedLanguages = languageSummary.OrderBy(o => o.Language).ToList(); | ||
|
||
//Add a total line if we need one | ||
if (includeTotal == true) | ||
{ | ||
sortedLanguages.Add(new LanguageSummary { Language = "total languages", Count = total }); | ||
} | ||
return sortedLanguages; | ||
} | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace DotNetCensus.Core.Models | ||
{ | ||
public class FrameworkSummary | ||
{ | ||
public string Framework { get; set; } = ""; | ||
public string FrameworkFamily { get; set; } = ""; | ||
public int Count { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace DotNetCensus.Core.Models | ||
{ | ||
public class LanguageSummary | ||
{ | ||
public string Language { get; set; } = ""; | ||
public int Count { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace DotNetCensus.Core.Models | ||
{ | ||
public class Project | ||
{ | ||
//public Project(string fileName, string path, string framework) | ||
//{ | ||
// FileName = fileName; | ||
// Path = path; | ||
// Framework = framework; | ||
//} | ||
|
||
public string FileName { get; set; } = ""; | ||
public string Path { get; set; } = ""; | ||
public string Framework { get; set; } = ""; | ||
public string? Language { get; set; } | ||
public string? Family { get; set; } | ||
public string? Color { get; set; } | ||
|
||
//public string? Content { get; set; } | ||
|
||
} | ||
} |
3 changes: 2 additions & 1 deletion
3
src/DotnetCensus.Tests/BaseTests.cs → src/DotNetCensus.Tests/BaseTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.