Skip to content

Commit b4978cb

Browse files
avivkellerovflowd
authored andcommitted
fix(search): use advanced search
1 parent 0bdee79 commit b4978cb

File tree

5 files changed

+22
-37
lines changed

5 files changed

+22
-37
lines changed

create-node-meeting-artifacts.mjs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,7 @@ const gitHubAgendaIssues = await github.getAgendaIssues(
5151
);
5252

5353
// Step 10: Parse meeting agenda from GitHub issues
54-
const meetingAgenda = meetings.generateMeetingAgenda(
55-
gitHubAgendaIssues,
56-
meetingConfig
57-
);
54+
const meetingAgenda = meetings.generateMeetingAgenda(gitHubAgendaIssues);
5855

5956
// Step 11: Create HackMD document with meeting notes and tags
6057
const hackmdNote = await hackmd.createMeetingNotesDocument(

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/constants.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@ export const HACKMD_DEFAULT_PERMISSIONS = {
3434
writePermission: 'signed_in',
3535
commentPermission: 'signed_in_users',
3636
};
37+
38+
export const REPOSITORY_URL_PREFIX_LENGTH = 'https://api.github.com/repos/'
39+
.length;

src/github.mjs

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Octokit } from '@octokit/rest';
22

3-
import { DEFAULT_CONFIG } from './constants.mjs';
3+
import { DEFAULT_CONFIG, REPOSITORY_URL_PREFIX_LENGTH } from './constants.mjs';
44

55
/**
66
* Creates a GitHub API client
@@ -47,36 +47,26 @@ export const createGitHubIssue = async (
4747
* @param {import('@octokit/rest').Octokit} githubClient - Authenticated GitHub API client
4848
* @param {import('./types.d.ts').AppConfig} config - Application configuration
4949
* @param {import('./types.d.ts').MeetingConfig} meetingConfig - Meeting configuration
50-
* @returns {Promise<{ repoName: string, issues: Array<GitHubIssue> }> } Formatted markdown string of issues
50+
* @returns {Promise<{ [key: string]: Array<GitHubIssue> }>} Formatted markdown string of issues
5151
*/
5252
export const getAgendaIssues = async (
53-
{ paginate, rest },
53+
githubClient,
5454
{ meetingGroup },
5555
{ properties }
5656
) => {
5757
const githubOrg = properties.USER ?? DEFAULT_CONFIG.githubOrg;
5858
const agendaTag = properties.AGENDA_TAG ?? `${meetingGroup}-agenda`;
5959

60-
// Get all public repositories in the organization
61-
const repos = await paginate(rest.repos.listForOrg, {
62-
org: githubOrg,
63-
type: 'public',
64-
per_page: 100,
60+
// Get all issues/PRs in the organization
61+
const issues = await githubClient.paginate('GET /search/issues', {
62+
q: `label:${agendaTag} org:${githubOrg}`,
63+
advanced_search: true,
6564
});
6665

67-
// Fetch issues and PRs from all repositories concurrently
68-
const issuePromises = repos.map(async repo => {
69-
const items = await paginate(rest.issues.listForRepo, {
70-
owner: githubOrg,
71-
repo: repo.name,
72-
labels: agendaTag,
73-
state: 'open',
74-
per_page: 100,
75-
});
76-
77-
// Include both issues and PRs for agenda items
78-
return { repoName: repo.name, issues: items };
79-
});
80-
81-
return Promise.all(issuePromises);
66+
return issues.reduce((obj, issue) => {
67+
(obj[issue.repository_url.slice(REPOSITORY_URL_PREFIX_LENGTH)] ||= []).push(
68+
issue
69+
);
70+
return obj;
71+
}, {});
8272
};

src/meeting.mjs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,16 @@ export const generateMeetingTitle = (config, meetingConfig, meetingDate) => {
5656

5757
/**
5858
* Generates the meeting agenda from the list of agenda issues
59-
* @param {Array<{ repoName: string, issues: Array<GitHubIssue> }>} agendaIssues - List of agenda issues
60-
* @param {import('./types.d.ts').MeetingConfig} meetingConfig - Meeting configuration
59+
* @param {Array<{ [key: string]: Array<GitHubIssue> }>} agendaIssues - List of agenda issues
6160
* @returns {Promise<string>} Formatted meeting agenda
6261
*/
63-
export const generateMeetingAgenda = (agendaIssues, meetingConfig) => {
64-
const props = meetingConfig.properties;
65-
66-
const githubOrg = props.USER ?? DEFAULT_CONFIG.githubOrg;
67-
62+
export const generateMeetingAgenda = agendaIssues => {
6863
// Format issues as markdown
6964
let agendaMarkdown = '';
7065

71-
agendaIssues.forEach(({ repoName, issues }) => {
66+
Object.entries(agendaIssues).forEach(([repoName, issues]) => {
7267
if (issues.length > 0) {
73-
agendaMarkdown += `### ${githubOrg}/${repoName}\n\n`;
68+
agendaMarkdown += `### ${repoName}\n\n`;
7469

7570
issues.forEach(issue => {
7671
// Escape markdown characters in title

0 commit comments

Comments
 (0)