-
-
Notifications
You must be signed in to change notification settings - Fork 632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: fixed dashboard scripts #3304
Changes from all commits
c8e5b24
2888676
4058ced
d762073
f2c1e1a
fca64ae
0f14a3d
339ac4f
433f38d
79611d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
name: List everyday latest list of AsyncAPI Meetings, Newsroom Videos and Dashboard data. | ||
|
||
on: | ||
on: | ||
workflow_dispatch: | ||
schedule: | ||
#every day at midnight | ||
|
@@ -23,7 +23,7 @@ jobs: | |
- name: Check package-lock version | ||
uses: asyncapi/.github/.github/actions/get-node-version-from-package-lock@master | ||
id: lockversion | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
|
@@ -45,7 +45,7 @@ jobs: | |
committer: asyncapi-bot <[email protected]> | ||
author: asyncapi-bot <[email protected]> | ||
title: 'chore: update meetings.json and newsrooom_videos.json' | ||
branch: update-meetings/${{ github.job }} | ||
branch: update-meetings/${{ github.sha }} | ||
- if: failure() # Only, on failure, send a message on the 94_bot-failing-ci slack channel | ||
name: Report workflow run status to Slack | ||
uses: 8398a7/action-slack@fbd6aa58ba854a740e11a35d0df80cb5d12101d8 #using https://github.com/8398a7/action-slack/releases/tag/v3.15.1 | ||
|
@@ -54,4 +54,4 @@ jobs: | |
fields: repo,action,workflow | ||
text: 'AsyncAPI Meetings and Videos workflow failed' | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CI_FAIL_NOTIFY }} | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CI_FAIL_NOTIFY }} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,34 +1,90 @@ | ||||||||||||||||||||||||||||||||||||||||
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) { | ||||||||||||||||||||||||||||||||||||||||
const result = await Promise.all( | ||||||||||||||||||||||||||||||||||||||||
discussions.map(async (discussion) => { | ||||||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||||||
* Introduces a delay in the execution flow. | ||||||||||||||||||||||||||||||||||||||||
* @param {number} ms - The number of milliseconds to pause. | ||||||||||||||||||||||||||||||||||||||||
* @returns {Promise<void>} A promise that resolves after the specified delay. | ||||||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||||||
async function pause(ms) { | ||||||||||||||||||||||||||||||||||||||||
return new Promise((res) => { | ||||||||||||||||||||||||||||||||||||||||
setTimeout(res, ms); | ||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
async function getDiscussions(query, pageSize, endCursor = null) { | ||||||||||||||||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||||||||||||||||
const result = await graphql(query, { | ||||||||||||||||||||||||||||||||||||||||
first: pageSize, | ||||||||||||||||||||||||||||||||||||||||
after: endCursor, | ||||||||||||||||||||||||||||||||||||||||
headers: { | ||||||||||||||||||||||||||||||||||||||||
authorization: `token ${process.env.GITHUB_TOKEN}` | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
if (result.rateLimit.remaining <= 100) { | ||||||||||||||||||||||||||||||||||||||||
console.log( | ||||||||||||||||||||||||||||||||||||||||
`[WARNING] GitHub GraphQL rateLimit`, | ||||||||||||||||||||||||||||||||||||||||
`cost = ${result.rateLimit.cost}`, | ||||||||||||||||||||||||||||||||||||||||
`limit = ${result.rateLimit.limit}`, | ||||||||||||||||||||||||||||||||||||||||
`remaining = ${result.rateLimit.remaining}`, | ||||||||||||||||||||||||||||||||||||||||
`resetAt = ${result.rateLimit.resetAt}` | ||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
await pause(500); | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
const { hasNextPage } = result.search.pageInfo; | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
if (!hasNextPage) { | ||||||||||||||||||||||||||||||||||||||||
return result.search.nodes; | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
return result.search.nodes.concat(await getDiscussions(query, pageSize, result.search.pageInfo.endCursor)); | ||||||||||||||||||||||||||||||||||||||||
} catch (e) { | ||||||||||||||||||||||||||||||||||||||||
console.error(e); | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
return Promise.reject(e); | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
async function getDiscussionByID(isPR, id) { | ||||||||||||||||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||||||||||||||||
const result = await graphql(isPR ? Queries.pullRequestById : Queries.issueById, { | ||||||||||||||||||||||||||||||||||||||||
id, | ||||||||||||||||||||||||||||||||||||||||
headers: { | ||||||||||||||||||||||||||||||||||||||||
authorization: `token ${process.env.GITHUB_TOKEN}` | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
return result; | ||||||||||||||||||||||||||||||||||||||||
} catch (e) { | ||||||||||||||||||||||||||||||||||||||||
console.error(e); | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
return Promise.reject(e); | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
async function processHotDiscussions(batch) { | ||||||||||||||||||||||||||||||||||||||||
return Promise.all( | ||||||||||||||||||||||||||||||||||||||||
batch.map(async (discussion) => { | ||||||||||||||||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||||||||||||||||
// eslint-disable-next-line no-underscore-dangle | ||||||||||||||||||||||||||||||||||||||||
const isPR = discussion.__typename === 'PullRequest'; | ||||||||||||||||||||||||||||||||||||||||
if (discussion.comments.pageInfo.hasNextPage) { | ||||||||||||||||||||||||||||||||||||||||
let fetchedDiscussion = await getDiscussionByID(isPR, discussion.id); | ||||||||||||||||||||||||||||||||||||||||
const fetchedDiscussion = await getDiscussionByID(isPR, discussion.id); | ||||||||||||||||||||||||||||||||||||||||
discussion = fetchedDiscussion.node; | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
const interactionsCount = | ||||||||||||||||||||||||||||||||||||||||
discussion.reactions.totalCount + | ||||||||||||||||||||||||||||||||||||||||
discussion.comments.totalCount + | ||||||||||||||||||||||||||||||||||||||||
discussion.comments.nodes.reduce( | ||||||||||||||||||||||||||||||||||||||||
(acc, curr) => acc + curr.reactions.totalCount, | ||||||||||||||||||||||||||||||||||||||||
0 | ||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||
discussion.comments.nodes.reduce((acc, curr) => acc + curr.reactions.totalCount, 0); | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
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, | ||||||||||||||||||||||||||||||||||||||||
|
@@ -37,130 +93,84 @@ | |||||||||||||||||||||||||||||||||||||||
title: discussion.title, | ||||||||||||||||||||||||||||||||||||||||
author: discussion.author ? discussion.author.login : '', | ||||||||||||||||||||||||||||||||||||||||
resourcePath: discussion.resourcePath, | ||||||||||||||||||||||||||||||||||||||||
repo: 'asyncapi/' + discussion.repository.name, | ||||||||||||||||||||||||||||||||||||||||
repo: `asyncapi/${discussion.repository.name}`, | ||||||||||||||||||||||||||||||||||||||||
labels: discussion.labels ? discussion.labels.nodes : [], | ||||||||||||||||||||||||||||||||||||||||
score: | ||||||||||||||||||||||||||||||||||||||||
finalInteractionsCount / | ||||||||||||||||||||||||||||||||||||||||
Math.pow(monthsSince(discussion.timelineItems.updatedAt) + 2, 1.8), | ||||||||||||||||||||||||||||||||||||||||
score: finalInteractionsCount / (monthsSince(discussion.timelineItems.updatedAt) + 2) ** 1.8 | ||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||
} catch (e) { | ||||||||||||||||||||||||||||||||||||||||
console.error( | ||||||||||||||||||||||||||||||||||||||||
`there was some issues while parsing this item: ${JSON.stringify( | ||||||||||||||||||||||||||||||||||||||||
discussion | ||||||||||||||||||||||||||||||||||||||||
)}` | ||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||
console.error(`there was some issues while parsing this item: ${JSON.stringify(discussion)}`); | ||||||||||||||||||||||||||||||||||||||||
throw e; | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
async function getHotDiscussions(discussions) { | ||||||||||||||||||||||||||||||||||||||||
const result = []; | ||||||||||||||||||||||||||||||||||||||||
const batchSize = 5; | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
for (let i = 0; i < discussions.length; i += batchSize) { | ||||||||||||||||||||||||||||||||||||||||
const batch = discussions.slice(i, i + batchSize); | ||||||||||||||||||||||||||||||||||||||||
// eslint-disable-next-line no-await-in-loop | ||||||||||||||||||||||||||||||||||||||||
const batchResults = await processHotDiscussions(batch); | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
// eslint-disable-next-line no-await-in-loop | ||||||||||||||||||||||||||||||||||||||||
await pause(1000); | ||||||||||||||||||||||||||||||||||||||||
Comment on lines
+110
to
+118
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider making batch parameters configurable. The batch size and pause duration are currently hardcoded. Consider making these configurable through environment variables for easier tuning: +const BATCH_SIZE = parseInt(process.env.GITHUB_API_BATCH_SIZE, 10) || 5;
+const BATCH_PAUSE_MS = parseInt(process.env.GITHUB_API_BATCH_PAUSE_MS, 10) || 1000;
- const batchSize = 5;
+ const batchSize = BATCH_SIZE;
- await pause(1000);
+ await pause(BATCH_PAUSE_MS); 📝 Committable suggestion
Suggested change
🧰 Tools🪛 GitHub Check: codecov/patch
|
||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
result.push(...batchResults); | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
result.sort((ElemA, ElemB) => ElemB.score - ElemA.score); | ||||||||||||||||||||||||||||||||||||||||
const filteredResult = result.filter(issue => issue.author !== 'asyncapi-bot'); | ||||||||||||||||||||||||||||||||||||||||
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, ' ') | ||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||
writeFileSync(resolve(__dirname, '..', '..', 'dashboard.json'), JSON.stringify(content, null, ' ')); | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
async function mapGoodFirstIssues(issues) { | ||||||||||||||||||||||||||||||||||||||||
return issues.map((issue) => ({ | ||||||||||||||||||||||||||||||||||||||||
id: issue.id, | ||||||||||||||||||||||||||||||||||||||||
title: issue.title, | ||||||||||||||||||||||||||||||||||||||||
isAssigned: !!issue.assignees.totalCount, | ||||||||||||||||||||||||||||||||||||||||
resourcePath: issue.resourcePath, | ||||||||||||||||||||||||||||||||||||||||
repo: 'asyncapi/' + issue.repository.name, | ||||||||||||||||||||||||||||||||||||||||
repo: `asyncapi/${issue.repository.name}`, | ||||||||||||||||||||||||||||||||||||||||
author: issue.author.login, | ||||||||||||||||||||||||||||||||||||||||
area: getLabel(issue, 'area/') || 'Unknown', | ||||||||||||||||||||||||||||||||||||||||
labels: issue.labels.nodes.filter( | ||||||||||||||||||||||||||||||||||||||||
(label) => | ||||||||||||||||||||||||||||||||||||||||
!label.name.startsWith('area/') && | ||||||||||||||||||||||||||||||||||||||||
!label.name.startsWith('good first issue') | ||||||||||||||||||||||||||||||||||||||||
), | ||||||||||||||||||||||||||||||||||||||||
(label) => !label.name.startsWith('area/') && !label.name.startsWith('good first issue') | ||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||
})); | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
function getLabel(issue, filter) { | ||||||||||||||||||||||||||||||||||||||||
const result = issue.labels.nodes.find((label) => | ||||||||||||||||||||||||||||||||||||||||
label.name.startsWith(filter) | ||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||
return result && result.name.split('/')[1]; | ||||||||||||||||||||||||||||||||||||||||
const result = issue.labels.nodes.find((label) => label.name.startsWith(filter)); | ||||||||||||||||||||||||||||||||||||||||
return 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; | ||||||||||||||||||||||||||||||||||||||||
return Math.floor(months); | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
async function getDiscussions(query, pageSize, endCursor = null) { | ||||||||||||||||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||||||||||||||||
let result = await graphql(query, { | ||||||||||||||||||||||||||||||||||||||||
first: pageSize, | ||||||||||||||||||||||||||||||||||||||||
after: endCursor, | ||||||||||||||||||||||||||||||||||||||||
headers: { | ||||||||||||||||||||||||||||||||||||||||
authorization: `token ${process.env.GITHUB_TOKEN}`, | ||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
if (result.rateLimit.remaining <= 100) { | ||||||||||||||||||||||||||||||||||||||||
console.log( | ||||||||||||||||||||||||||||||||||||||||
`[WARNING] GitHub GraphQL rateLimit`, | ||||||||||||||||||||||||||||||||||||||||
`cost = ${result.rateLimit.cost}`, | ||||||||||||||||||||||||||||||||||||||||
`limit = ${result.rateLimit.limit}`, | ||||||||||||||||||||||||||||||||||||||||
`remaining = ${result.rateLimit.remaining}`, | ||||||||||||||||||||||||||||||||||||||||
`resetAt = ${result.rateLimit.resetAt}` | ||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
const hasNextPage = result.search.pageInfo.hasNextPage; | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
if (!hasNextPage) { | ||||||||||||||||||||||||||||||||||||||||
return result.search.nodes; | ||||||||||||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||||||||||||
return result.search.nodes.concat( | ||||||||||||||||||||||||||||||||||||||||
await getDiscussions(query, pageSize, result.search.pageInfo.endCursor) | ||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
} catch (e) { | ||||||||||||||||||||||||||||||||||||||||
console.error(e); | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
async function getDiscussionByID(isPR, id) { | ||||||||||||||||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||||||||||||||||
let result = await graphql(isPR ? Queries.pullRequestById : Queries.issueById, { | ||||||||||||||||||||||||||||||||||||||||
id, | ||||||||||||||||||||||||||||||||||||||||
headers: { | ||||||||||||||||||||||||||||||||||||||||
authorization: `token ${process.env.GITHUB_TOKEN}`, | ||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||
return result; | ||||||||||||||||||||||||||||||||||||||||
} catch (e) { | ||||||||||||||||||||||||||||||||||||||||
console.error(e); | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
async function start() { | ||||||||||||||||||||||||||||||||||||||||
try { | ||||||||||||||||||||||||||||||||||||||||
const [issues, PRs, rawGoodFirstIssues] = await Promise.all([ | ||||||||||||||||||||||||||||||||||||||||
getDiscussions(Queries.hotDiscussionsIssues, 20), | ||||||||||||||||||||||||||||||||||||||||
getDiscussions(Queries.hotDiscussionsPullRequests, 20), | ||||||||||||||||||||||||||||||||||||||||
getDiscussions(Queries.goodFirstIssues, 20), | ||||||||||||||||||||||||||||||||||||||||
getDiscussions(Queries.goodFirstIssues, 20) | ||||||||||||||||||||||||||||||||||||||||
]); | ||||||||||||||||||||||||||||||||||||||||
const discussions = issues.concat(PRs); | ||||||||||||||||||||||||||||||||||||||||
const [hotDiscussions, goodFirstIssues] = await Promise.all([ | ||||||||||||||||||||||||||||||||||||||||
getHotDiscussions(discussions), | ||||||||||||||||||||||||||||||||||||||||
mapGoodFirstIssues(rawGoodFirstIssues), | ||||||||||||||||||||||||||||||||||||||||
mapGoodFirstIssues(rawGoodFirstIssues) | ||||||||||||||||||||||||||||||||||||||||
]); | ||||||||||||||||||||||||||||||||||||||||
writeToFile({ hotDiscussions, goodFirstIssues }); | ||||||||||||||||||||||||||||||||||||||||
} catch (e) { | ||||||||||||||||||||||||||||||||||||||||
console.log('There were some issues parsing data from github.') | ||||||||||||||||||||||||||||||||||||||||
console.log('There were some issues parsing data from github.'); | ||||||||||||||||||||||||||||||||||||||||
console.log(e); | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
start(); | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
module.exports = { getLabel, monthsSince, mapGoodFirstIssues, getHotDiscussions, getDiscussionByID } | ||||||||||||||||||||||||||||||||||||||||
module.exports = { getLabel, monthsSince, mapGoodFirstIssues, getHotDiscussions, getDiscussionByID }; | ||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Simplify Error Handling by Throwing Errors Directly
In
async
functions, instead of returningPromise.reject(e);
, it's cleaner to throw the error directly usingthrow e;
. This makes the code more idiomatic and easier to read.Apply this diff:
Also applies to: 59-59
🧰 Tools
🪛 GitHub Check: codecov/patch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will improve this readiness of the code in another PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@akshatnema, understood. Would you like me to open a new GitHub issue to track this improvement?
🐰😔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure 👍 . Please do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@akshatnema, I've opened a new GitHub issue to track this improvement: Issue #3305.
🐰😊
🔗 Analysis chain
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 597