diff --git a/index.js b/index.js index 2f94917..a3dfd1d 100644 --- a/index.js +++ b/index.js @@ -14,15 +14,15 @@ const endDate = new Date('2020-12-30T23:59:59Z'); const repos = require('./repos.json'); -const giteaReviews = new GiteaReviews(process.env.GITEA_TOKEN, kreditsAmounts); +async function getAllReviews(repos, startDate, endDate) { + const githubReviews = new GithubReviews(process.env.GITHUB_TOKEN, kreditsAmounts); + const giteaReviews = new GiteaReviews(process.env.GITEA_TOKEN, kreditsAmounts); -giteaReviews.getReviewContributions(repos.gitea, startDate, endDate).then(reviewContributions => { - console.log('GITEA REVIEW CONTRIBUTIONS', reviewContributions); -}); - -const githubReviews = new GithubReviews(process.env.GITHUB_TOKEN, kreditsAmounts); - -githubReviews.getReviewContributions(repos.github, startDate, endDate).then(reviewContributions => { - console.log('GITHUB REVIEW CONTRIBUTIONS', reviewContributions); -}); + return Promise.all([ + githubReviews.getReviewContributions(repos.github, startDate, endDate), + giteaReviews.getReviewContributions(repos.gitea, startDate, endDate) + ]).then(reviews => { + return { github: reviews[0], gitea: reviews[1] } + }); +}