Skip to content

Commit

Permalink
Merge pull request #30 from IowaComputerGurus/feature/chart-by-action
Browse files Browse the repository at this point in the history
Added Minutes per File Summary #29
  • Loading branch information
mitchelsellers committed Jan 10, 2024
2 parents 04c7093 + 6c33fdd commit 0d43ca5
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/GitHubCostVisualizer.Web/Models/GithubUsageEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ public class GithubUsageEntry
public string Username { get; set; }
[Name("Notes")]
public string Notes { get; set; }
public string TrimmedWorkflow => ActionWorkflow?.Replace(".github/workflows/", "");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class UsageReportViewModel
public decimal TotalActionMinutesCost { get; set; }
public List<KeyValuePair<string, int>> ActionsSummary { get; set; }
public List<KeyValuePair<string, int>> ActionMinutesByRepository { get; set; }
public List<KeyValuePair<string, int>> ActionMinutesByWorkflow { get; set; }
public decimal AverageDailyStorage { get; set; }
public List<KeyValuePair<DateTime, decimal>> DailyStorageSummary { get; set; }
public List<KeyValuePair<string, decimal>> AverageDailyStorageByRepo { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using GitHubCostVisualizer.Web.Models;

namespace GitHubCostVisualizer.Web.Processor
Expand Down Expand Up @@ -34,7 +35,12 @@ into grp
group x by x.Repository
into grp
select new KeyValuePair<string, int>(grp.Key, grp.Sum(i => (int)i.Quantity))).ToList();

model.ActionMinutesByWorkflow = (from x in entries.Where(i =>
i.Product.Equals(Constants.GitHubProducts.Actions, StringComparison.InvariantCultureIgnoreCase))
group x by new { x.Repository, x.TrimmedWorkflow }
into grp
select new KeyValuePair<string, int>($"{grp.Key.Repository} - {grp.Key.TrimmedWorkflow}",
grp.Sum(i => (int)i.Quantity))).ToList();
model.DailyStorageSummary = (from x in entries.Where(i => i.Product.Equals(Constants.GitHubProducts.SharedStorage, StringComparison.InvariantCultureIgnoreCase))
group x by x.Date
into grp
Expand Down
27 changes: 27 additions & 0 deletions src/GitHubCostVisualizer.Web/Views/Home/_ActionDetail.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@
aria-selected="False">
Chart (By Repo)
</a>
<a class="nav-item nav-link" id="nav-tab-action-workflow-list-tab"
data-toggle="tab"
href="#nav-tab-action-workflow-list"
role="tab"
aria-controls="nav-tab-action-workflow-list"
aria-selected="True">
List (By Workflow)
</a>
<a class="nav-item nav-link"
id="nav-tab-action-system-list-tab"
data-toggle="tab"
Expand Down Expand Up @@ -98,6 +106,25 @@
});
</script>
</div>
<div class="tab-pane" id="nav-tab-action-workflow-list" role="tabpanel" aria-labelledby="nav-tab-action-workflow-list-tab">
<table class="display w-100">
<thead>
<tr>
<th>Workflow (Repository - File)</th>
<th>Minutes</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.ActionMinutesByWorkflow)
{
<tr>
<td>@item.Key</td>
<td data-sort="@item.Value">@item.Value minutes</td>
</tr>
}
</tbody>
</table>
</div>
<div class="tab-pane fade" id="nav-tab-action-system-list" role="tabpanel" aria-labelledby="nav-tab-action-system-list-tab">
<table class="display w-100">
<thead>
Expand Down
2 changes: 1 addition & 1 deletion src/GitHubCostVisualizer.Web/Views/Shared/_Start.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
View on <a href="https://github.com/IowaComputerGurus/github-cost-visualizer">Github</a>
</p>
<p class="text-center">
<small>This is a free service provided by <a href="https://www.iowacomputergurus.com">IowaComputerGurus, Inc.</a> <a href="https://www.iowacomputergurus.com/privacy">Privacy Policy</a></small>
This is a free service provided by <a href="https://www.iowacomputergurus.com">IowaComputerGurus, Inc.</a> <a href="https://www.iowacomputergurus.com/privacy">Privacy Policy</a>
</p>
</div>
</div>
Expand Down

0 comments on commit 0d43ca5

Please sign in to comment.