From f414ef3363e90994e12a2709dd2b15210742206f Mon Sep 17 00:00:00 2001 From: Andrei Ignat Date: Wed, 16 Oct 2024 19:41:04 +0300 Subject: [PATCH] display inverse --- .../HtmlSummary.cshtml | 27 ++++++++++++++----- .../Templates/MDSummary.cshtml | 9 ++++++- .../Templates/NamePerCountDisplay.cshtml | 12 ++++++--- .../NamePerCountDisplayThreshold.cshtml | 8 ++++-- .../NetPackageAnalyzerObjects/ProjectsDict.cs | 7 +++++ .../NetPackageAnalyzerObjects/many.cs | 1 + 6 files changed, 51 insertions(+), 13 deletions(-) diff --git a/src/NetPackageAnalyzer/NetPackageAnalyzerExportHTML/HtmlSummary.cshtml b/src/NetPackageAnalyzer/NetPackageAnalyzerExportHTML/HtmlSummary.cshtml index feb7143..cb1bc3f 100644 --- a/src/NetPackageAnalyzer/NetPackageAnalyzerExportHTML/HtmlSummary.cshtml +++ b/src/NetPackageAnalyzer/NetPackageAnalyzerExportHTML/HtmlSummary.cshtml @@ -31,9 +31,9 @@ maxCommitString = "this year," + currentYear; } var maxCommitFiles = projectDicts.CommitsWithMaxFiles(null); - var top10Files = projectDicts.FilesWithMaxCommits(null); + NamePerCountArray topFiles = projectDicts.FilesWithMaxCommitsAdv(null)??NamePerCountArray.Empty; var medianCommits = projectDicts.MedianCommits(null); - KeyValuePair? filewithMaxCommits = top10Files?.Length > 0 ? top10Files.First() : null; + var filewithMaxCommits = topFiles?.First1(); Tuple tuple; Tuple tupleThreshold; NamePerCountDisplayThreshold namePerCountDisplayThreshold; @@ -310,7 +310,7 @@ @(++tableRow) - + last commit : @maxCommitString @@ -319,13 +319,18 @@ @(++tableRow) - The commit with max files ( @maxCommitFiles.CountFiles() ) is sha @(maxCommitFiles.sha) on @maxCommitFiles.date.ToString("yyyy MMMM dd") ) + + The commit with max files + + ( @maxCommitFiles.CountFiles() ) is sha @(maxCommitFiles.sha) on @maxCommitFiles.date.ToString("yyyy MMMM dd") ) @(++tableRow) - The file with most commits ( @filewithMaxCommits?.Value ) is @GlobalsForGenerating.RelativePath(filewithMaxCommits?.Key) + + The file with most commits + ( @filewithMaxCommits?.Count ) is @GlobalsForGenerating.RelativePath(filewithMaxCommits?.Name) @@ -1259,6 +1264,16 @@ columns: [ @yearFolders.Render() +

Commits per file

+ + @{ + tuple = new(topFiles!, "Files with commits"); + namePerCountDisplay = new(tuple); + + } + @namePerCountDisplay.Render(); + + } @@ -1266,7 +1281,7 @@ columns: [ @{ var maxCommitFilesPerYear = projectDicts.CommitsWithMaxFilesPerYear(); } -

Commits with most files per year

+

Commits with most files per year

diff --git a/src/NetPackageAnalyzer/NetPackageAnalyzerExportHTML/Templates/MDSummary.cshtml b/src/NetPackageAnalyzer/NetPackageAnalyzerExportHTML/Templates/MDSummary.cshtml index 16c9012..29ed50b 100644 --- a/src/NetPackageAnalyzer/NetPackageAnalyzerExportHTML/Templates/MDSummary.cshtml +++ b/src/NetPackageAnalyzer/NetPackageAnalyzerExportHTML/Templates/MDSummary.cshtml @@ -51,4 +51,11 @@ ## Commits -![Number-exec-lines-per-method](./images/@(nameFolder)/commits-year-project.png) + +### File with most commits + +![Files-with-commits](./images/@(nameFolder)/Files-with-commits.png) + +### Commits per year and project + +![Commits per year and project](./images/@(nameFolder)/commits-year-project.png) diff --git a/src/NetPackageAnalyzer/NetPackageAnalyzerExportHTML/Templates/NamePerCountDisplay.cshtml b/src/NetPackageAnalyzer/NetPackageAnalyzerExportHTML/Templates/NamePerCountDisplay.cshtml index 1af3d77..13eedcc 100644 --- a/src/NetPackageAnalyzer/NetPackageAnalyzerExportHTML/Templates/NamePerCountDisplay.cshtml +++ b/src/NetPackageAnalyzer/NetPackageAnalyzerExportHTML/Templates/NamePerCountDisplay.cshtml @@ -40,7 +40,7 @@ { nameCountGraphic = nameCount.Take(10).ToArray(); } - string assNamesMaintIndex = string.Join(",", nameCountGraphic.Select(it => "'" + it.Name + "'")); + string assNamesMaintIndex = string.Join(",", nameCountGraphic.Select(it => "'" + it.Name.Replace("\\", "\\\\") + "'")); string valuesMaintIndex = string.Join(",\r\n", nameCountGraphic.Select(it => "{value:" + it.Count +"}") ); @@ -63,11 +63,11 @@ var option; option = { - xAxis: { + yAxis: { type: 'category', data: [@assNamesMaintIndex] }, - yAxis: { + xAxis: { type: 'value' }, tooltip: { @@ -80,6 +80,10 @@ @valuesMaintIndex ], type: 'bar' + , label: { + show: true, + formatter: '{c}' + } } ] }; @@ -120,7 +124,7 @@ bar @yAxis @foreach (var item in nameCountOriginal) { - {"Name": "@item.Name", "Nr": "@item.Count" }, + {"Name": "@item.Name.Replace("\\", "\\\\")", "Nr": "@item.Count" }, } ]; diff --git a/src/NetPackageAnalyzer/NetPackageAnalyzerExportHTML/Templates/NamePerCountDisplayThreshold.cshtml b/src/NetPackageAnalyzer/NetPackageAnalyzerExportHTML/Templates/NamePerCountDisplayThreshold.cshtml index b33d6d3..1c164bc 100644 --- a/src/NetPackageAnalyzer/NetPackageAnalyzerExportHTML/Templates/NamePerCountDisplayThreshold.cshtml +++ b/src/NetPackageAnalyzer/NetPackageAnalyzerExportHTML/Templates/NamePerCountDisplayThreshold.cshtml @@ -69,11 +69,11 @@ var option; option = { - xAxis: { + yAxis: { type: 'category', data: [@assNamesMaintIndex] }, - yAxis: { + xAxis: { type: 'value' }, tooltip: { @@ -86,6 +86,10 @@ @valuesMaintIndex ], type: 'bar' + , label: { + show: true, + formatter: '{c}' + } } ] }; diff --git a/src/NetPackageAnalyzer/NetPackageAnalyzerObjects/ProjectsDict.cs b/src/NetPackageAnalyzer/NetPackageAnalyzerObjects/ProjectsDict.cs index aa0d11f..51e609f 100644 --- a/src/NetPackageAnalyzer/NetPackageAnalyzerObjects/ProjectsDict.cs +++ b/src/NetPackageAnalyzer/NetPackageAnalyzerObjects/ProjectsDict.cs @@ -46,6 +46,13 @@ public int MedianCommits(int? year) return StatisticalNumbers.Median(data.Select(it => it.Value).ToArray()); } + public NamePerCountArray FilesWithMaxCommitsAdv(int? year) + { + var data= FilesWithMaxCommits(year) + .Select(it => new NamePerCount(it.Key, it.Value)) + .ToArray(); + return new NamePerCountArray(data,true); + } public KeyValuePair[] FilesWithMaxCommits(int? year) { int take = 10; diff --git a/src/NetPackageAnalyzer/NetPackageAnalyzerObjects/many.cs b/src/NetPackageAnalyzer/NetPackageAnalyzerObjects/many.cs index 3a055a6..36eb5d0 100644 --- a/src/NetPackageAnalyzer/NetPackageAnalyzerObjects/many.cs +++ b/src/NetPackageAnalyzer/NetPackageAnalyzerObjects/many.cs @@ -44,6 +44,7 @@ public record NamePerCount(string Name, long Count) } public record NamePerCountArray(NamePerCount[]? NamePerCounts,bool Descending) { + public static NamePerCountArray Empty = new NamePerCountArray([], false); public Statistics Statistics() { return new Statistics(