MCPcopy
hub / github.com/iptv-org/iptv / loadDiscussions

Function loadDiscussions

scripts/utils.ts:221–260  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

219}
220
221export async function loadDiscussions() {
222 let discussions: object[] = []
223 if (TESTING) {
224 discussions = (await import('../tests/__data__/input/discussions.js')).default
225 } else {
226 const CustomOctokit = Octokit.plugin(paginateGraphQL)
227 const octokit = new CustomOctokit({
228 auth: process.env.GITHUB_TOKEN
229 })
230
231 const query = `
232 query ($owner: String!, $repo: String!, $cursor: String) {
233 repository(owner: $owner, name: $repo) {
234 discussions(first: 100, after: $cursor, states: OPEN) {
235 nodes {
236 number
237 body
238 category {
239 name
240 }
241 }
242 pageInfo {
243 endCursor
244 hasNextPage
245 }
246 }
247 }
248 }
249 `
250
251 const result = await octokit.graphql.paginate(query, {
252 owner: 'iptv-org',
253 repo: 'iptv'
254 })
255
256 discussions = result.repository.discussions.nodes
257 }
258
259 return new Collection(discussions).map(parseDiscussion)
260}
261
262function parseDiscussion(discussion: {
263 number: number

Callers 1

mainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected