From e390c376e50501ce8fab6f562c9ff6ad040595b4 Mon Sep 17 00:00:00 2001 From: lakshaydiwan Date: Sat, 19 Oct 2024 23:40:48 +0530 Subject: [PATCH 1/2] fix: Mis-linked page #3300 --- config/edit-page-config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/edit-page-config.json b/config/edit-page-config.json index dbd5fa50b9e..32921f145d4 100644 --- a/config/edit-page-config.json +++ b/config/edit-page-config.json @@ -13,7 +13,7 @@ }, { "value": "", - "href": "https://github.com/asyncapi/website/blob/master/pages" + "href": "https://github.com/asyncapi/website/blob/master/markdown" }, { "value": "reference/extensions/", From eb7ca25fdead66076146ac2a7edbe78c6e9b062f Mon Sep 17 00:00:00 2001 From: lakshaydiwan Date: Mon, 21 Oct 2024 16:16:18 +0530 Subject: [PATCH 2/2] fix:Simplify error handling(#3305) --- scripts/dashboard/build-dashboard.js | 46 ++++++++++++++++------------ 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/scripts/dashboard/build-dashboard.js b/scripts/dashboard/build-dashboard.js index 49fbf8b5d4f..d1aa79e78db 100644 --- a/scripts/dashboard/build-dashboard.js +++ b/scripts/dashboard/build-dashboard.js @@ -1,7 +1,6 @@ const { writeFileSync } = require('fs'); const { resolve } = require('path'); const { graphql } = require('@octokit/graphql'); -const { Promise } = require('node-fetch'); const { Queries } = require('./issue-queries'); async function getHotDiscussions(discussions) { @@ -24,12 +23,13 @@ async function getHotDiscussions(discussions) { const finalInteractionsCount = isPR ? interactionsCount + - discussion.reviews.totalCount + - discussion.reviews.nodes.reduce( - (acc, curr) => acc + curr.comments.totalCount, - 0 - ) + discussion.reviews.totalCount + + discussion.reviews.nodes.reduce( + (acc, curr) => acc + curr.comments.totalCount, + 0 + ) : interactionsCount; + return { id: discussion.id, isPR, @@ -45,7 +45,7 @@ async function getHotDiscussions(discussions) { }; } catch (e) { console.error( - `there was some issues while parsing this item: ${JSON.stringify( + `There were some issues while parsing this item: ${JSON.stringify( discussion )}` ); @@ -57,12 +57,14 @@ async function getHotDiscussions(discussions) { const filteredResult = result.filter(issue => issue.author !== 'asyncapi-bot'); return filteredResult.slice(0, 12); } + async function writeToFile(content) { writeFileSync( resolve(__dirname, '..', '..', 'dashboard.json'), JSON.stringify(content, null, ' ') ); } + async function mapGoodFirstIssues(issues) { return issues.map((issue) => ({ id: issue.id, @@ -87,11 +89,9 @@ function getLabel(issue, filter) { return result && result.name.split('/')[1]; } - function monthsSince(date) { const seconds = Math.floor((new Date() - new Date(date)) / 1000); - // 2592000 = number of seconds in a month = 30 * 24 * 60 * 60 - const months = seconds / 2592000; + const months = seconds / 2592000; // 2592000 = seconds in a month return Math.floor(months); } @@ -112,7 +112,7 @@ async function getDiscussions(query, pageSize, endCursor = null) { `limit = ${result.rateLimit.limit}`, `remaining = ${result.rateLimit.remaining}`, `resetAt = ${result.rateLimit.resetAt}` - ) + ); } const hasNextPage = result.search.pageInfo.hasNextPage; @@ -125,9 +125,11 @@ async function getDiscussions(query, pageSize, endCursor = null) { ); } } catch (e) { - console.error(e); + console.error('Error fetching discussions:', e); + throw e; } } + async function getDiscussionByID(isPR, id) { try { let result = await graphql(isPR ? Queries.pullRequestById : Queries.issueById, { @@ -135,14 +137,14 @@ async function getDiscussionByID(isPR, id) { headers: { authorization: `token ${process.env.GITHUB_TOKEN}`, }, - - } - ); + }); return result; } catch (e) { - console.error(e); + console.error(`Error fetching discussion by ID: ${id}`, e); + throw e; } } + async function start() { try { const [issues, PRs, rawGoodFirstIssues] = await Promise.all([ @@ -150,17 +152,21 @@ async function start() { getDiscussions(Queries.hotDiscussionsPullRequests, 20), getDiscussions(Queries.goodFirstIssues, 20), ]); + const discussions = issues.concat(PRs); const [hotDiscussions, goodFirstIssues] = await Promise.all([ getHotDiscussions(discussions), mapGoodFirstIssues(rawGoodFirstIssues), ]); - writeToFile({ hotDiscussions, goodFirstIssues }); + + await writeToFile({ hotDiscussions, goodFirstIssues }); } catch (e) { - console.log('There were some issues parsing data from github.') - console.log(e); + console.log('There were some issues parsing data from GitHub.'); + console.error(e); + throw e; } } + start(); -module.exports = { getLabel, monthsSince, mapGoodFirstIssues, getHotDiscussions, getDiscussionByID } \ No newline at end of file +module.exports = { getLabel, monthsSince, mapGoodFirstIssues, getHotDiscussions, getDiscussionByID };