11import { Octokit } from '@octokit/rest' ;
22
3- import { DEFAULT_CONFIG , REPOSITORY_URL_PREFIX_LENGTH } from './constants.mjs' ;
3+ import { DEFAULT_CONFIG } from './constants.mjs' ;
44
55/**
66 * Creates a GitHub API client
@@ -42,12 +42,25 @@ export const createGitHubIssue = async (
4242 return response . data ;
4343} ;
4444
45+ /**
46+ * Sorts issues by repository
47+ * @param {Array<GitHubIssue> } issues The issues to sort
48+ * @returns {Promise<{ [key: string]: Array<GitHubIssue> }> } Sorted issues
49+ */
50+ export const sortIssuesByRepo = issues =>
51+ issues . reduce ( ( obj , issue ) => {
52+ ( obj [ issue . repository_url . split ( '/' ) . slice ( - 2 ) . join ( '/' ) ] ||= [ ] ) . push (
53+ issue
54+ ) ;
55+ return obj ;
56+ } , { } ) ;
57+
4558/**
4659 * Fetches GitHub issues from all repositories in an organization with a specific label
4760 * @param {import('@octokit/rest').Octokit } githubClient - Authenticated GitHub API client
4861 * @param {import('./types.d.ts').AppConfig } config - Application configuration
4962 * @param {import('./types.d.ts').MeetingConfig } meetingConfig - Meeting configuration
50- * @returns {Promise<{ [key: string]: Array<GitHubIssue> }> } Formatted markdown string of issues
63+ * @returns {Promise<{ [key: string]: Array<GitHubIssue> }> } Meeting agenda
5164 */
5265export const getAgendaIssues = async (
5366 githubClient ,
@@ -59,14 +72,9 @@ export const getAgendaIssues = async (
5972
6073 // Get all issues/PRs in the organization
6174 const issues = await githubClient . paginate ( 'GET /search/issues' , {
62- q : `label:${ agendaTag } org:${ githubOrg } ` ,
75+ q : `is:open label:${ agendaTag } org:${ githubOrg } ` ,
6376 advanced_search : true ,
6477 } ) ;
6578
66- return issues . reduce ( ( obj , issue ) => {
67- ( obj [ issue . repository_url . slice ( REPOSITORY_URL_PREFIX_LENGTH ) ] ||= [ ] ) . push (
68- issue
69- ) ;
70- return obj ;
71- } , { } ) ;
79+ return sortIssuesByRepo ( issues ) ;
7280} ;
0 commit comments