|
| 1 | +using Newtonsoft.Json; |
| 2 | +using Octokit; |
| 3 | +using System; |
| 4 | +using System.Collections.Generic; |
| 5 | +using System.IO; |
| 6 | +using System.Linq; |
| 7 | +using System.Threading.Tasks; |
| 8 | + |
| 9 | +namespace GithubIssueTagger.Reports |
| 10 | +{ |
| 11 | + internal class BacklogIssuesByType : IReport |
| 12 | + { |
| 13 | + private GitHubClient _client; |
| 14 | + private QueryCache _queryCache; |
| 15 | + |
| 16 | + public BacklogIssuesByType(GitHubClient client, QueryCache queryCache) |
| 17 | + { |
| 18 | + _client = client ?? throw new ArgumentNullException(nameof(client)); |
| 19 | + _queryCache = queryCache ?? throw new ArgumentNullException(nameof(queryCache)); |
| 20 | + } |
| 21 | + |
| 22 | + public async Task RunAsync() |
| 23 | + { |
| 24 | + var issues = await IssueUtilities.GetIssuesForAnyMatchingLabelsAsync(_client, "nuget", "home", "Priority:1", "Priority:2"); |
| 25 | + var outputFileName = "home.issues"; |
| 26 | + var json = JsonConvert.SerializeObject(issues, Formatting.Indented); |
| 27 | + File.WriteAllText(outputFileName, json); |
| 28 | + |
| 29 | + Dictionary<string, int> keyValuePairs = new Dictionary<string, int>() |
| 30 | + { |
| 31 | + { "Type:Bug", 0 }, |
| 32 | + { "Type:DCR", 0 }, |
| 33 | + { "Type:Feature", 0 }, |
| 34 | + { "Type:Test", 0 }, |
| 35 | + { "Type:Engineering", 0 }, |
| 36 | + { "Type:Tracking", 0 }, |
| 37 | + { "Type:DataAnalysis", 0 }, |
| 38 | + { "Type:Docs", 0 }, |
| 39 | + { "Type:DeveloperDocs", 0 }, |
| 40 | + { "Type:Spec", 0 }, |
| 41 | + }; |
| 42 | + |
| 43 | + foreach (var issue in issues) |
| 44 | + { |
| 45 | + foreach (var label in issue.Labels) |
| 46 | + { |
| 47 | + if (keyValuePairs.ContainsKey(label.Name)) |
| 48 | + { |
| 49 | + keyValuePairs[label.Name] += 1; |
| 50 | + } |
| 51 | + } |
| 52 | + } |
| 53 | + foreach (var kvp in keyValuePairs) |
| 54 | + { |
| 55 | + Console.WriteLine($"{kvp.Key} : {kvp.Value}"); |
| 56 | + } |
| 57 | + } |
| 58 | + } |
| 59 | +} |
0 commit comments