Skip to content

Commit

Permalink
use search API instead
Browse files Browse the repository at this point in the history
  • Loading branch information
goaaats committed Feb 1, 2024
1 parent 0f058ae commit 5610e84
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions Plogon/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;

using Discord;

using Octokit;

using Serilog;

namespace Plogon;
Expand Down Expand Up @@ -627,12 +628,19 @@ private static async Task DoPacRoundRobinAssign(GitHubApi gitHubApi, int prNumbe
string? loginToAssign;

// Find the last new plugin PR
var prs = await gitHubApi.Client.PullRequest.GetAllForRepository(gitHubApi.RepoOwner, gitHubApi.RepoName);
var lastNewPluginPr = prs?.OrderBy(x => x.Number)
.FirstOrDefault(x =>
x.Labels.Any(y => y.Name == PlogonSystemDefine.PR_LABEL_NEW_PLUGIN) &&
x.Number != prNumber);

//var prs = await gitHubApi.Client.PullRequest.GetAllForRepository(gitHubApi.RepoOwner, gitHubApi.RepoName);
var result = await gitHubApi.Client.Search.SearchIssues(
new SearchIssuesRequest
{
Repos = new RepositoryCollection()
{
{ gitHubApi.RepoOwner, gitHubApi.RepoName },
},
Is = new [] { IssueIsQualifier.PullRequest },
Labels = new []{ PlogonSystemDefine.PR_LABEL_NEW_PLUGIN },
SortField = IssueSearchSort.Created,
});
var lastNewPluginPr = result?.Items.FirstOrDefault(x => x.Number != prNumber);
if (lastNewPluginPr == null)
{
Log.Error("Could not find last new plugin PR for round robin assign");
Expand Down

0 comments on commit 5610e84

Please sign in to comment.