public async Task <int> UpdateGitHubActionPullRequests(string clientId, string clientSecret, TableStorageAuth tableStorageAuth, string owner, string repo, string branch, int numberOfDays, int maxNumberOfItems) { GitHubAPIAccess api = new GitHubAPIAccess(); JArray items = await api.GetGitHubPullRequestsJArray(clientId, clientSecret, owner, repo, branch); int itemsAdded = 0; TableStorageCommonDA tableDA = new TableStorageCommonDA(tableStorageAuth, tableStorageAuth.TableGitHubPRs); //Check each build to see if it's in storage, adding the items not in storage foreach (JToken item in items) { GitHubPR pr = JsonConvert.DeserializeObject <GitHubPR>(item.ToString()); if (pr.state == "closed") { string partitionKey = CreateGitHubPRPartitionKey(owner, repo); string rowKey = pr.number; AzureStorageTableModel newItem = new AzureStorageTableModel(partitionKey, rowKey, item.ToString()); if (await tableDA.AddItem(newItem) == true) { itemsAdded++; } itemsAdded += await UpdateGitHubActionPullRequestCommits(clientId, clientSecret, tableStorageAuth, owner, repo, pr.number); } } return(itemsAdded); }
public async Task <GitHubPR> GetGitHubPullRequest(string clientId, string clientSecret, TableStorageAuth tableStorageAuth, string owner, string repo, string branch, bool useCache) { List <GitHubPR> prs = new List <GitHubPR>(); Newtonsoft.Json.Linq.JArray list; if (useCache == true) { //Get the pull requests from Azure storage AzureTableStorageDA daTableStorage = new AzureTableStorageDA(); list = daTableStorage.GetTableStorageItems(tableStorageAuth, tableStorageAuth.TableGitHubPRs, daTableStorage.CreateGitHubPRPartitionKey(owner, repo)); } else { //Get the pull requests from the GitHub API GitHubAPIAccess api = new GitHubAPIAccess(); list = await api.GetGitHubPullRequestsJArray(clientId, clientSecret, owner, repo, branch); } if (list != null) { prs = JsonConvert.DeserializeObject <List <GitHubPR> >(list.ToString()); } //Find the PR id GitHubPR pr = null; foreach (GitHubPR item in prs) { if (item.head.@ref == branch) { pr = item; break; } } return(pr); }