Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/features/issues/server/github-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,12 @@ export async function searchGitHubIssues({
queryParts.push(linkedPrQualifier);
}

const displayQuery = repoTopicQuery
? [repoTopicQuery, `label:${quoteSearchValue(label)}`, linkedPrQualifier]
.filter(Boolean)
.join(" ")
: queryParts.join(" ");

const repoBatches =
repoTopicQuery && matchingRepos.length > 0
? Array.from(
Expand All @@ -288,7 +294,7 @@ export async function searchGitHubIssues({

if (repoTopicQuery && repoBatches.length === 0) {
return {
query: repoTopicQuery,
query: displayQuery,
totalCount: 0,
candidateCount: 0,
rateLimitRemaining: null,
Expand All @@ -307,7 +313,6 @@ export async function searchGitHubIssues({
].join(" "),
)
: [queryParts.join(" ")];
const query = issueQueries.join(" | ");

const searchUrls = issueQueries.flatMap((issueQuery) => {
const pageNumbers =
Expand All @@ -328,7 +333,10 @@ export async function searchGitHubIssues({
const searchResults = await Promise.all(
searchUrls.map((url) => githubFetch<GitHubSearchResponse>(url, token, 180)),
);
const totalCount = searchResults[0]?.data.total_count ?? 0;
const totalCount =
repoBatches.length > 0
? searchResults.reduce((count, result) => count + result.data.total_count, 0)
: searchResults[0]?.data.total_count ?? 0;
const rateLimitRemaining = searchResults.at(-1)?.rateLimitRemaining ?? null;
const candidateIssues = dedupeIssues(searchResults.flatMap((result) => result.data.items));
const repoEntriesFromSearch = matchingRepos.map((repo) => [repo.full_name, repo] as const);
Expand Down Expand Up @@ -446,7 +454,7 @@ export async function searchGitHubIssues({
}));

return {
query,
query: displayQuery,
totalCount,
candidateCount: rankedIssues.length,
rateLimitRemaining,
Expand Down
3 changes: 3 additions & 0 deletions tests/features/issues/server/github-search.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ describe("searchGitHubIssues", () => {
"is:issue is:open archived:false label:\"help wanted\" repo:spring-projects/spring-boot",
);
expect(issueQuery).not.toContain("Spring Boot");
expect(result.query).toBe(
'topic:spring-boot archived:false language:Java label:"help wanted"',
);
expect(result.issues[0]).toMatchObject({
repo: "spring-projects/spring-boot",
stars: 82000,
Expand Down