diff --git a/dist/community-toolbox.js b/dist/community-toolbox.js index d66ba599..e6176fc2 100644 --- a/dist/community-toolbox.js +++ b/dist/community-toolbox.js @@ -81690,11 +81690,13 @@ function insertIssue(issue, el) { function insertStale(issues, selector) { - let issuesLen = issues.length; - $('#stale-head').html('Stale Issues ('+issuesLen+'+)'); - issues.forEach(function (issue) { - insertIssue(issue, selector); - }) + // if(issues!=null && issues!=undefined ) { + // let issuesLen = issues.length; + // $('#stale-head').html('Stale Issues ('+issuesLen+'+)'); + // issues.forEach(function (issue) { + // insertIssue(issue, selector); + // }) + // } } @@ -82050,30 +82052,35 @@ CommunityToolbox = function CommunityToolbox(org, repo) { return fetchReposUtil.getAllRepos(org) .then((resp) => { resolve(true); - }); + }) + .catch((err) => { + Snackbar.show({pos: 'top-right', text: err, textColor: "red" , showAction: false}); + }) } resolve(true); }); - }); + }) }); - } + } function dropdownInit() { - return model_utils.getItem('repos').then((res) => { + return model_utils.getItem('repos') + .then((res) => { if(res!=null && res!=undefined) { autoCompleteUtil.generateAutocomplete(res); }else { console.log("not working"); } - }); + }) } // This function is responsible for showing contributors // on a multi-repository view function showAllContributors(org) { - return contributorsUtil.fetchAllContribsInDb(org).then((allContributors) => { + return contributorsUtil.fetchAllContribsInDb(org) + .then((allContributors) => { // If the stored data is not undefined or null, execution goes here if(allContributors!=null && allContributors!=undefined && allContributors.length>0) { // Flushes contributors list from the database after every single day @@ -82093,18 +82100,22 @@ CommunityToolbox = function CommunityToolbox(org, repo) { // If the data is not in the database, it gets fetched from storeAllContributorsInDatabase function if(AllContributors == null || AllContributors == undefined || AllContributors.length==0) { - contributorsUtil.fetchAllContribsInDb(org).then(function gotAllContributors(AllContributors) { - // Provides fetched contributors list to UI function for rendering it - // to the user - contributorsUI.insertContributors(AllContributors); - }) - } + contributorsUtil.fetchAllContribsInDb(org) + .then(function gotAllContributors(AllContributors) { + // Provides fetched contributors list to UI function for rendering it + // to the user + contributorsUI.insertContributors(AllContributors); + }) + .catch((err) => { + throw err; + }) + } // If stored data is not null and undefined, process it else { contributorsUI.insertContributors(AllContributors); } }) - }); + }) } // If execution goes here, it means that there's probably something wrong // in the storeAllContributorsInDatabase function @@ -82112,12 +82123,16 @@ CommunityToolbox = function CommunityToolbox(org, repo) { console.log("Something went wrong while fetching all contributors :("); } }) + .catch((err) => { + Snackbar.show({pos: 'top-right', text: err, textColor: "red" , showAction: false}); + }) } // This function is responsible for showing all the contributors for a particular repository function showRepoContributors(org, repo) { - return contributorsUtil.fetchAllContribsInDb(org).then((allContributors) => { + return contributorsUtil.fetchAllContribsInDb(org) + .then((allContributors) => { // If the stored data is not undefined or null, execution goes here if(allContributors != null && allContributors!=undefined && allContributors.length>0) { // Flushes repoContributors from the database after every single day @@ -82141,6 +82156,9 @@ CommunityToolbox = function CommunityToolbox(org, repo) { contributorsUI.insertContributors(contributors); return; }) + .catch((err) => { + throw err; + }) } // If we have repoContributors in the database, we save a network call :) else { @@ -82155,47 +82173,64 @@ CommunityToolbox = function CommunityToolbox(org, repo) { console.log(`Something went wrong while getting ${repo} contributors :(`); } }) + .catch((err) => { + Snackbar.show({pos: 'top-right', text: err, textColor: "red" , showAction: false}); + }) } // Function for fetching and showing recent contributors function showRecentContributors(org, repo, recencyLabel) { - return recentContribsUtil.fetchAllRecentContribsInDb(org, repo).then((result)=>{ + return recentContribsUtil.fetchAllRecentContribsInDb(org, repo) + .then((result) => { if(recencyLabel==='month') { return recentContribsUtil.fetchContribsLastMonth(org, repo) .then(function gotCommits(commits) { // Push data to UI recentContributorsUI.insertRecentContributors(commits); return; - }); + }) + .catch((err) => { + throw err; + }) } else { return recentContribsUtil.fetchContribsLastWeek(org, repo) .then((weekly_contribs) => { // Push data to UI recentContributorsUI.insertRecentContributors(weekly_contribs); return; - }); + }) + .catch((err) => { + throw err; + }) } - }); + }) + .catch((err) => { + Snackbar.show({pos: 'top-right', text: err, textColor: "red" , showAction: false}); + }) } function displayIssuesForRepo(org, repo, label, selector) { toolbox.api.Issues - .getIssuesForRepo(org, repo, { qs: { labels: label } }) - .then(function onGotIssues(issues) { - issues.forEach(function(issue) { - toolbox.issuesUI.insertIssue(issue, selector); - }); - }); + .getIssuesForRepo(org, repo, { qs: { labels: label } }) + .then(function onGotIssues(issues) { + issues.forEach(function(issue) { + toolbox.issuesUI.insertIssue(issue, selector); + }); + }) } function showStaleIssues(org, repo) { - return issuesUtil.getStaleIssues(org, repo).then((data)=>{ + return issuesUtil.getStaleIssues(org, repo) + .then((data) => { if(data!=null && data!=undefined) { issuesUI.insertStale(data, '.stale'); } }) + .catch((err) => { + Snackbar.show({pos: 'top-right', text: err, textColor: "red" , showAction: false}); + }) } @@ -82274,44 +82309,50 @@ function fetchAllRepoContribs(org, repo) { let contributorsArray = []; return api.Repositories - .getRepoContributors(org, repo, {method: "HEAD", qs: { sort: 'pushed', direction: 'desc', per_page: 100 } }) - .then(function gotContribData(contribData) { - var headers = contribData; - if (headers.hasOwnProperty("link")) { - var parsed = parse(headers['link']); - if(parsed.last.page!=undefined) { - totalPages = parseInt(parsed.last.page); - } - } else { - totalPages = 1; - } - return totalPages; - }) - .then(function gotTotalPages(totalPages) { - // This array is used to store all of the promises - let promises = []; - - for(let i = 1; i <= totalPages; i++) { - var currentPromise = api.Repositories - .getRepoContributors(org, repo, { method:"GET", qs: { sort: 'pushed', direction: 'desc', per_page: 100, page:i } }) - .then(function gotRepoContributors(contributors) { - if (contributors!=undefined && (contributors != null || contributors.length > 0)) { - contributors.map((contributor, i) => contributorsArray.push(contributor)); - } - }); - // Push currentPromise to promises array - promises.push(currentPromise); + .getRepoContributors(org, repo, {method: "HEAD", qs: { sort: 'pushed', direction: 'desc', per_page: 100 } }) + .then(function gotContribData(contribData) { + var headers = contribData; + if (headers.hasOwnProperty("link")) { + var parsed = parse(headers['link']); + if(parsed.last.page!=undefined) { + totalPages = parseInt(parsed.last.page); } + } else { + totalPages = 1; + } + return totalPages; + }) + .then(function gotTotalPages(totalPages) { + // This array is used to store all of the promises + let promises = []; + + for(let i = 1; i <= totalPages; i++) { + var currentPromise = api.Repositories + .getRepoContributors(org, repo, { method:"GET", qs: { sort: 'pushed', direction: 'desc', per_page: 100, page:i } }) + .then(function gotRepoContributors(contributors) { + if (contributors!=undefined && (contributors != null || contributors.length > 0)) { + contributors.map((contributor, i) => contributorsArray.push(contributor)); + } + }) + .catch((err) => { + throw err; + }); + // Push currentPromise to promises array + promises.push(currentPromise); + } - // Waits for all of the promises to resolve first, sets localStorage after that... - return Promise.all(promises) - .then(()=> { - let now = (new Date).getTime(); - model_utils.setItem(repo, contributorsArray); - model_utils.setItem(`${repo}Expiry`, now); - return contributorsArray; - }); - }); + // Waits for all of the promises to resolve first, sets localStorage after that... + return Promise.all(promises) + .then(()=> { + let now = (new Date).getTime(); + model_utils.setItem(repo, contributorsArray); + model_utils.setItem(`${repo}Expiry`, now); + return contributorsArray; + }); + }) + .catch((err) => { + throw err; + }) } @@ -82345,6 +82386,9 @@ function fetchRepoContribs(org, repo) { model_utils.setItem(`${repo}Expiry`, now); return contributorsArray; }) + .catch((err) => { + throw err; + }) } @@ -82385,6 +82429,10 @@ function fetchAllContribsInDb(org) { .then((response) => { return response; }) + .catch((err) => { + console.log("err travelling through fetchAllContribsInDb"); + throw err; + }) } @@ -82393,6 +82441,10 @@ function repoContribsUtil(org, repo) { .then((response) => { return response; }) + .catch((err) => { + console.log("err travelling through repoContribsUtil"); + throw err; + }) } @@ -82417,44 +82469,50 @@ function storeAllContribsInDb(org) { var contributorSet = new Set([]); return new Promise((resolve, reject) => { model_utils.getItem('allContributors').then((allContributors) => { - // If all contributors list is not in the database, it makes a fresh call to Github API - if(allContributors == null || allContributors == undefined || allContributors.length == 0) { - return model_utils.getItem('repos').then((res) => { + // If all contributors list is not in the database, it makes a fresh call to Github API + if(allContributors == null || allContributors == undefined || allContributors.length == 0) { + return model_utils.getItem('repos').then((res) => { let splicedRepos = res.splice(0, 20); splicedRepos.map(function mappingToEachRepo(Repo, i) { let promise = fetchRepoContributorsUtil.fetchRepoContributorsUtil(org, Repo) - .then(function gotRepoContributorsInStorage(contributors) { - if(contributors!=undefined && contributors.length>0) { - contributors.map((contributor, i)=> { - if(!contributorSet.has(contributor.login)) { - contributorSet.add(contributor.login); - AllContributors.push(contributor); - } - }) - } - }); - promises.push(promise); + .then(function gotRepoContributorsInStorage(contributors) { + if(contributors!=undefined && contributors.length>0) { + contributors.map((contributor, i)=> { + if(!contributorSet.has(contributor.login)) { + contributorSet.add(contributor.login); + AllContributors.push(contributor); + } + }) + } + }) + .catch((err) => { + throw err; + }) + promises.push(promise); }); return Promise.all(promises) - .then(()=> { - // Storing array containing all the contributors' list across 20 most active - // repos to database - model_utils.setItem('allContributors', AllContributors); - // Saves current time in epoch, used for flushing out the stored data - // after 24 hours - let currentTime = (new Date).getTime(); - model_utils.setItem('allContributorsExpiry', currentTime); - resolve(AllContributors); - }) - }) - } - // If all contributors list is in the database, it simply returns that as a resolved promise - else { - resolve(allContributors); - } + .then(()=> { + // Storing array containing all the contributors' list across 20 most active + // repos to database + model_utils.setItem('allContributors', AllContributors); + // Saves current time in epoch, used for flushing out the stored data + // after 24 hours + let currentTime = (new Date).getTime(); + model_utils.setItem('allContributorsExpiry', currentTime); + resolve(AllContributors); + }) + }) + } + // If all contributors list is in the database, it simply returns that as a resolved promise + else { + resolve(allContributors); + } }) - }); - } + .catch((err) => { + reject(err); + }) + }); +} @@ -82480,6 +82538,8 @@ function fetchAllRecentMonthContribs(org, repos, queryTime) { .then(function gotResponse(response) { if(response.status=="200") { return response.json(); + }else { + throw `Couldn't fetch recent contributors for ${repo}`; } }) .then(function gotResponseJson(response) { @@ -82501,7 +82561,10 @@ function fetchAllRecentMonthContribs(org, repos, queryTime) { model_utils.setItem(`recent-${repo}-month-expiry`, currTime); } return true; - }); + }) + .catch((err) => { + throw err; + }) }); return Promise.all(promises) @@ -82531,6 +82594,8 @@ function fetchRecentMonthContribs(org, repo, queryTime) { .then(function gotResponse(response) { if(response.status=="200") { return response.json(); + }else { + throw `Couldn't fetch recent contributors for ${repo}`; } }) .then(function gotResponseJson(response) { @@ -82551,7 +82616,11 @@ function fetchRecentMonthContribs(org, repo, queryTime) { model_utils.setItem(`recent-${repo}-month-expiry`, currTime); } return result; - }); + }) + .catch((err) => { + console.log("throwing from fetchRecentMonthContribs"); + throw err; + }) } @@ -82570,7 +82639,8 @@ let fetchRecentMonthContribs = require('./fetchRecentMonthContribs') // Fetches recent month's commits for a particular repo or all of the repos (10 repos) function getContribsLastMonth(org, repo) { - return model_utils.getItem('repos').then((repos) => { + return model_utils.getItem('repos') + .then((repos) => { if(repos!=null && repos!=undefined) { return model_utils.getItem(`recent-${repo}-month-expiry`) .then((recentCommitsMonthExpiry) => { @@ -82597,18 +82667,30 @@ function getContribsLastMonth(org, repo) { if(repo==='all') { return fetchAllRecentMonthContribs.fetchAllRecentMonthContribs(org, repos, queryTime) .then(function gotRecentCommitsInStorage(month_commits) { - return month_commits; - }); + return month_commits; + }) + .catch((err) => { + console.log("throwing from getContribsLastMonth"); + throw err; + }) } else { return fetchRecentMonthContribs.fetchRecentMonthContribs(org, repo, queryTime) .then(function gotRecentCommitsInStorage(month_commits) { - return month_commits; - }) + return month_commits; + }) + .catch((err) => { + console.log("throwing from getContribsLastMonth"); + throw err; + }) } } }) }) + .catch((err) => { + console.log("finally throwing from getContribsLastMonth"); + throw err; + }); } else { console.log("repos are not there yet!!!"); } @@ -82690,6 +82772,10 @@ function fetchContribsLastMonth(org, repo) { .then((contribs) => { return contribs; }) + .catch((err) => { + console.log("finally throwing"); + throw err; + }) } function fetchContribsLastWeek(org, repo) { @@ -82697,6 +82783,10 @@ function fetchContribsLastWeek(org, repo) { .then((contribs) => { return contribs; }) + .catch((err) => { + console.log("finally throwing"); + throw err; + }) } function fetchAllRecentContribsInDb(org, repo) { @@ -82704,6 +82794,10 @@ function fetchAllRecentContribsInDb(org, repo) { .then((response) => { return response; }) + .catch((err) => { + console.log("finally throwing"); + throw err; + }) } @@ -82727,33 +82821,43 @@ function storeAllRecentContribsInDb(org, repo) { let d = (new Date); d.setDate(d.getDate() - 30); let queryTime = d.toISOString(); - return model_utils.getItem('repos').then((repos) => { + return model_utils.getItem('repos') + .then((repos) => { return model_utils.getItem('recent-present').then((result)=> { - if(result!=null && result!=undefined) { + if(result!=null && result!=undefined) { return result; - } - else { + } + else { if(repos!=null || repos!=undefined) { - return fetchAllRecentMonthContribs.fetchAllRecentMonthContribs(org, repos, queryTime) - .then((result) => { - model_utils.setItem('recent-present', 'true'); - return result; - }) + return fetchAllRecentMonthContribs.fetchAllRecentMonthContribs(org, repos, queryTime) + .then((result) => { + model_utils.setItem('recent-present', 'true'); + return result; + }) + .catch((err) => { + throw err; + }) } else { - fetchRepoUtil.getAllRepos(org).then((repos) => { - if(repos!=null || repos!=undefined) { - return fetchAllRecentMonthContribs.fetchAllRecentMonthContribs(org, repos, queryTime) - .then((result) => { + fetchRepoUtil.getAllRepos(org) + .then((repos) => { + if(repos!=null || repos!=undefined) { + return fetchAllRecentMonthContribs.fetchAllRecentMonthContribs(org, repos, queryTime) + .then((result) => { model_utils.setItem('recent-present', 'true'); return result; - }) - } - }); + }) + .catch((err) => { + throw err; + }) + } + }); } - } + } }); }) - + .catch((err) => { + throw err; + }) } @@ -82794,6 +82898,8 @@ function getAllRepos(org) { .then(function gotRepos(data) { if(data.status=='200') { return data.json(); + }else { + throw "Couldn't fetch repositories :("; } }) .then(function mapToEachRepo(results) { @@ -82807,6 +82913,9 @@ function getAllRepos(org) { model_utils.setItem('repos', repos); return(repos); }) + .catch((err) => { + throw err; + }) } @@ -82830,30 +82939,35 @@ function getOrgWideIssues(org) { }) .then(() => { return model_utils.getItem("staleIssues").then((issues) => { - let pages = 5; // we take 2 to stay under API limit + let pages = 5; // we take 5 to stay under API limit if(issues!=undefined && issues!=null) { return issues; } for(let i=1;i<=pages;i++) { let curr = fetch(`https://api.github.com/search/issues?q=is%3Aopen+org%3A${org}+page%3A${i}`) - .then((data) => { - if(data.status=='200') { - return data.json(); - } - }) - .then(function (data) { - if(data!=null && data!=undefined) { - data.items.map(function mappingToIssues(issue, index) { - let dateLastUpdated = new Date(`${issue.updated_at}`); - let lastDate = dateLastUpdated.getTime(); - let today = (new Date).getTime(); - if(Math.ceil(Math.abs(today - lastDate) / (1000*3600*24)) > 10 ) { - staleIssues.push(issue); - } - }) - } - }) + .then((data) => { + if(data.status=='200') { + return data.json(); + }else { + throw "Couldn't fetch issues"; + } + }) + .then(function (data) { + if(data!=null && data!=undefined) { + data.items.map(function mappingToIssues(issue, index) { + let dateLastUpdated = new Date(`${issue.updated_at}`); + let lastDate = dateLastUpdated.getTime(); + let today = (new Date).getTime(); + if(Math.ceil(Math.abs(today - lastDate) / (1000*3600*24)) > 10 ) { + staleIssues.push(issue); + } + }) + } + }) + .catch((err) => { + throw err; + }) totalPromises.push(curr); @@ -82867,16 +82981,23 @@ function getOrgWideIssues(org) { }) }) }) + .catch((err) => { + throw err; + }) } function getStaleIssues(org, repo) { - return getOrgWideIssues(org, repo).then((issues) => { + return getOrgWideIssues(org, repo) + .then((issues) => { if(issues!=undefined && issues!=null) { return issues; } }) + .catch((err) => { + throw err; + }) } diff --git a/index.html b/index.html index 0e5ab26d..01fabf10 100644 --- a/index.html +++ b/index.html @@ -9,10 +9,12 @@ Community toolbox + + diff --git a/package-lock.json b/package-lock.json index a76e19cb..4b27ab72 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1935,8 +1935,7 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -2338,8 +2337,7 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -2394,7 +2392,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -2438,14 +2435,12 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true } } }, @@ -2476,9 +2471,9 @@ } }, "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", + "version": "4.17.14", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.14.tgz", + "integrity": "sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==", "dev": true } } @@ -2898,9 +2893,9 @@ "dev": true }, "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha1-s56mIp72B+zYniyN8SU2iRysm40=", + "version": "4.17.14", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.14.tgz", + "integrity": "sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==", "dev": true }, "module-deps": { @@ -3005,9 +3000,9 @@ } }, "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", + "version": "4.17.14", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.14.tgz", + "integrity": "sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==", "dev": true } } @@ -3031,9 +3026,9 @@ }, "dependencies": { "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", + "version": "4.17.14", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.14.tgz", + "integrity": "sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==", "dev": true } } @@ -3084,9 +3079,9 @@ "dev": true }, "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", + "version": "4.17.14", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.14.tgz", + "integrity": "sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==", "dev": true }, "supports-color": { @@ -3116,9 +3111,9 @@ }, "dependencies": { "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", + "version": "4.17.14", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.14.tgz", + "integrity": "sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==", "dev": true } } @@ -4434,9 +4429,9 @@ "dev": true }, "mixin-deep": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz", - "integrity": "sha1-pJ5yaNzhoNlpjkUybFYm3zVD0P4=", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", + "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==", "dev": true, "requires": { "for-in": "^1.0.2", @@ -4446,7 +4441,7 @@ "is-extendable": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", - "integrity": "sha1-p0cPnkJnM9gb2B4RVSZOOjUHyrQ=", + "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", "dev": true, "requires": { "is-plain-object": "^2.0.4" @@ -4557,6 +4552,11 @@ } } }, + "node-snackbar": { + "version": "0.1.15", + "resolved": "https://registry.npmjs.org/node-snackbar/-/node-snackbar-0.1.15.tgz", + "integrity": "sha512-d0dRnIvqNx28lrawdEj91W4vAfz/0lmRmHIr3HHdqjOIGb4zq2vhVoGI/tOnobUFNkNrvlYGVLxsFex02MHmFA==" + }, "nopt": { "version": "3.0.6", "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", @@ -5417,9 +5417,9 @@ "dev": true }, "set-value": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", - "integrity": "sha1-ca5KiPD+77v1LR6mBPP7MV67YnQ=", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", + "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==", "dev": true, "requires": { "extend-shallow": "^2.0.1", @@ -6025,9 +6025,9 @@ } }, "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha1-s56mIp72B+zYniyN8SU2iRysm40=", + "version": "4.17.14", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.14.tgz", + "integrity": "sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==", "dev": true }, "strip-ansi": { @@ -6400,38 +6400,15 @@ } }, "union-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz", - "integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", + "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==", "dev": true, "requires": { "arr-union": "^3.1.0", "get-value": "^2.0.6", "is-extendable": "^0.1.1", - "set-value": "^0.4.3" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - }, - "set-value": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-0.4.3.tgz", - "integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=", - "dev": true, - "requires": { - "extend-shallow": "^2.0.1", - "is-extendable": "^0.1.1", - "is-plain-object": "^2.0.1", - "to-object-path": "^0.3.0" - } - } + "set-value": "^2.0.1" } }, "unique-string": { diff --git a/package.json b/package.json index e4078ed0..9d77702c 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "chart.js": "~2.8.0", "font-awesome": "~4.7.0", "jquery": "~3", + "node-snackbar": "^0.1.15", "parse-link-header": "^1.0.1", "urlhash": "~0.1.1" }, diff --git a/src/scripts/community-toolbox.js b/src/scripts/community-toolbox.js index 493512f6..8c5d2c0d 100644 --- a/src/scripts/community-toolbox.js +++ b/src/scripts/community-toolbox.js @@ -67,30 +67,35 @@ CommunityToolbox = function CommunityToolbox(org, repo) { return fetchReposUtil.getAllRepos(org) .then((resp) => { resolve(true); - }); + }) + .catch((err) => { + Snackbar.show({pos: 'top-right', text: err, textColor: "red" , showAction: false}); + }) } resolve(true); }); - }); + }) }); - } + } function dropdownInit() { - return model_utils.getItem('repos').then((res) => { + return model_utils.getItem('repos') + .then((res) => { if(res!=null && res!=undefined) { autoCompleteUtil.generateAutocomplete(res); }else { console.log("not working"); } - }); + }) } // This function is responsible for showing contributors // on a multi-repository view function showAllContributors(org) { - return contributorsUtil.fetchAllContribsInDb(org).then((allContributors) => { + return contributorsUtil.fetchAllContribsInDb(org) + .then((allContributors) => { // If the stored data is not undefined or null, execution goes here if(allContributors!=null && allContributors!=undefined && allContributors.length>0) { // Flushes contributors list from the database after every single day @@ -110,18 +115,22 @@ CommunityToolbox = function CommunityToolbox(org, repo) { // If the data is not in the database, it gets fetched from storeAllContributorsInDatabase function if(AllContributors == null || AllContributors == undefined || AllContributors.length==0) { - contributorsUtil.fetchAllContribsInDb(org).then(function gotAllContributors(AllContributors) { - // Provides fetched contributors list to UI function for rendering it - // to the user - contributorsUI.insertContributors(AllContributors); - }) - } + contributorsUtil.fetchAllContribsInDb(org) + .then(function gotAllContributors(AllContributors) { + // Provides fetched contributors list to UI function for rendering it + // to the user + contributorsUI.insertContributors(AllContributors); + }) + .catch((err) => { + throw err; + }) + } // If stored data is not null and undefined, process it else { contributorsUI.insertContributors(AllContributors); } }) - }); + }) } // If execution goes here, it means that there's probably something wrong // in the storeAllContributorsInDatabase function @@ -129,12 +138,16 @@ CommunityToolbox = function CommunityToolbox(org, repo) { console.log("Something went wrong while fetching all contributors :("); } }) + .catch((err) => { + Snackbar.show({pos: 'top-right', text: err, textColor: "red" , showAction: false}); + }) } // This function is responsible for showing all the contributors for a particular repository function showRepoContributors(org, repo) { - return contributorsUtil.fetchAllContribsInDb(org).then((allContributors) => { + return contributorsUtil.fetchAllContribsInDb(org) + .then((allContributors) => { // If the stored data is not undefined or null, execution goes here if(allContributors != null && allContributors!=undefined && allContributors.length>0) { // Flushes repoContributors from the database after every single day @@ -158,6 +171,9 @@ CommunityToolbox = function CommunityToolbox(org, repo) { contributorsUI.insertContributors(contributors); return; }) + .catch((err) => { + throw err; + }) } // If we have repoContributors in the database, we save a network call :) else { @@ -172,47 +188,64 @@ CommunityToolbox = function CommunityToolbox(org, repo) { console.log(`Something went wrong while getting ${repo} contributors :(`); } }) + .catch((err) => { + Snackbar.show({pos: 'top-right', text: err, textColor: "red" , showAction: false}); + }) } // Function for fetching and showing recent contributors function showRecentContributors(org, repo, recencyLabel) { - return recentContribsUtil.fetchAllRecentContribsInDb(org, repo).then((result)=>{ + return recentContribsUtil.fetchAllRecentContribsInDb(org, repo) + .then((result) => { if(recencyLabel==='month') { return recentContribsUtil.fetchContribsLastMonth(org, repo) .then(function gotCommits(commits) { // Push data to UI recentContributorsUI.insertRecentContributors(commits); return; - }); + }) + .catch((err) => { + throw err; + }) } else { return recentContribsUtil.fetchContribsLastWeek(org, repo) .then((weekly_contribs) => { // Push data to UI recentContributorsUI.insertRecentContributors(weekly_contribs); return; - }); + }) + .catch((err) => { + throw err; + }) } - }); + }) + .catch((err) => { + Snackbar.show({pos: 'top-right', text: err, textColor: "red" , showAction: false}); + }) } function displayIssuesForRepo(org, repo, label, selector) { toolbox.api.Issues - .getIssuesForRepo(org, repo, { qs: { labels: label } }) - .then(function onGotIssues(issues) { - issues.forEach(function(issue) { - toolbox.issuesUI.insertIssue(issue, selector); - }); - }); + .getIssuesForRepo(org, repo, { qs: { labels: label } }) + .then(function onGotIssues(issues) { + issues.forEach(function(issue) { + toolbox.issuesUI.insertIssue(issue, selector); + }); + }) } function showStaleIssues(org, repo) { - return issuesUtil.getStaleIssues(org, repo).then((data)=>{ + return issuesUtil.getStaleIssues(org, repo) + .then((data) => { if(data!=null && data!=undefined) { issuesUI.insertStale(data, '.stale'); } }) + .catch((err) => { + Snackbar.show({pos: 'top-right', text: err, textColor: "red" , showAction: false}); + }) } diff --git a/src/utils/contribsUtil/fetchAllRepoContribs.js b/src/utils/contribsUtil/fetchAllRepoContribs.js index cc2aac6a..6bbce2a1 100644 --- a/src/utils/contribsUtil/fetchAllRepoContribs.js +++ b/src/utils/contribsUtil/fetchAllRepoContribs.js @@ -9,44 +9,50 @@ function fetchAllRepoContribs(org, repo) { let contributorsArray = []; return api.Repositories - .getRepoContributors(org, repo, {method: "HEAD", qs: { sort: 'pushed', direction: 'desc', per_page: 100 } }) - .then(function gotContribData(contribData) { - var headers = contribData; - if (headers.hasOwnProperty("link")) { - var parsed = parse(headers['link']); - if(parsed.last.page!=undefined) { - totalPages = parseInt(parsed.last.page); - } - } else { - totalPages = 1; - } - return totalPages; - }) - .then(function gotTotalPages(totalPages) { - // This array is used to store all of the promises - let promises = []; - - for(let i = 1; i <= totalPages; i++) { - var currentPromise = api.Repositories - .getRepoContributors(org, repo, { method:"GET", qs: { sort: 'pushed', direction: 'desc', per_page: 100, page:i } }) - .then(function gotRepoContributors(contributors) { - if (contributors!=undefined && (contributors != null || contributors.length > 0)) { - contributors.map((contributor, i) => contributorsArray.push(contributor)); - } - }); - // Push currentPromise to promises array - promises.push(currentPromise); + .getRepoContributors(org, repo, {method: "HEAD", qs: { sort: 'pushed', direction: 'desc', per_page: 100 } }) + .then(function gotContribData(contribData) { + var headers = contribData; + if (headers.hasOwnProperty("link")) { + var parsed = parse(headers['link']); + if(parsed.last.page!=undefined) { + totalPages = parseInt(parsed.last.page); } + } else { + totalPages = 1; + } + return totalPages; + }) + .then(function gotTotalPages(totalPages) { + // This array is used to store all of the promises + let promises = []; - // Waits for all of the promises to resolve first, sets localStorage after that... - return Promise.all(promises) - .then(()=> { - let now = (new Date).getTime(); - model_utils.setItem(repo, contributorsArray); - model_utils.setItem(`${repo}Expiry`, now); - return contributorsArray; - }); - }); + for(let i = 1; i <= totalPages; i++) { + var currentPromise = api.Repositories + .getRepoContributors(org, repo, { method:"GET", qs: { sort: 'pushed', direction: 'desc', per_page: 100, page:i } }) + .then(function gotRepoContributors(contributors) { + if (contributors!=undefined && (contributors != null || contributors.length > 0)) { + contributors.map((contributor, i) => contributorsArray.push(contributor)); + } + }) + .catch((err) => { + throw err; + }); + // Push currentPromise to promises array + promises.push(currentPromise); + } + + // Waits for all of the promises to resolve first, sets localStorage after that... + return Promise.all(promises) + .then(()=> { + let now = (new Date).getTime(); + model_utils.setItem(repo, contributorsArray); + model_utils.setItem(`${repo}Expiry`, now); + return contributorsArray; + }); + }) + .catch((err) => { + throw err; + }) } diff --git a/src/utils/contribsUtil/fetchRepoContribs.js b/src/utils/contribsUtil/fetchRepoContribs.js index ce8c5971..af266dc7 100644 --- a/src/utils/contribsUtil/fetchRepoContribs.js +++ b/src/utils/contribsUtil/fetchRepoContribs.js @@ -21,6 +21,9 @@ function fetchRepoContribs(org, repo) { model_utils.setItem(`${repo}Expiry`, now); return contributorsArray; }) + .catch((err) => { + throw err; + }) } diff --git a/src/utils/contribsUtil/main.js b/src/utils/contribsUtil/main.js index 62d8abcd..3dcb0f9d 100644 --- a/src/utils/contribsUtil/main.js +++ b/src/utils/contribsUtil/main.js @@ -7,6 +7,10 @@ function fetchAllContribsInDb(org) { .then((response) => { return response; }) + .catch((err) => { + console.log("err travelling through fetchAllContribsInDb"); + throw err; + }) } @@ -15,6 +19,10 @@ function repoContribsUtil(org, repo) { .then((response) => { return response; }) + .catch((err) => { + console.log("err travelling through repoContribsUtil"); + throw err; + }) } diff --git a/src/utils/contribsUtil/storeAllContribsInDb.js b/src/utils/contribsUtil/storeAllContribsInDb.js index 3d473b91..8ebc0a2b 100644 --- a/src/utils/contribsUtil/storeAllContribsInDb.js +++ b/src/utils/contribsUtil/storeAllContribsInDb.js @@ -14,17 +14,20 @@ function storeAllContribsInDb(org) { return model_utils.getItem('repos').then((res) => { let splicedRepos = res.splice(0, 20); splicedRepos.map(function mappingToEachRepo(Repo, i) { - let promise = fetchRepoContributorsUtil.fetchRepoContributorsUtil(org, Repo) - .then(function gotRepoContributorsInStorage(contributors) { - if(contributors!=undefined && contributors.length>0) { - contributors.map((contributor, i)=> { - if(!contributorSet.has(contributor.login)) { - contributorSet.add(contributor.login); - AllContributors.push(contributor); - } - }) - } - }); + let promise = fetchRepoContributorsUtil.fetchRepoContributorsUtil(org, Repo) + .then(function gotRepoContributorsInStorage(contributors) { + if(contributors!=undefined && contributors.length>0) { + contributors.map((contributor, i)=> { + if(!contributorSet.has(contributor.login)) { + contributorSet.add(contributor.login); + AllContributors.push(contributor); + } + }) + } + }) + .catch((err) => { + throw err; + }) promises.push(promise); }); return Promise.all(promises) @@ -38,12 +41,15 @@ function storeAllContribsInDb(org) { model_utils.setItem('allContributorsExpiry', currentTime); resolve(AllContributors); }) - }) - } - // If all contributors list is in the database, it simply returns that as a resolved promise - else { - resolve(allContributors); - } + }) + } + // If all contributors list is in the database, it simply returns that as a resolved promise + else { + resolve(allContributors); + } + }) + .catch((err) => { + reject(err); }) }); } diff --git a/src/utils/recentContribsUtil/fetchAllRecentMonthContribs.js b/src/utils/recentContribsUtil/fetchAllRecentMonthContribs.js index b0d1529d..7a511823 100644 --- a/src/utils/recentContribsUtil/fetchAllRecentMonthContribs.js +++ b/src/utils/recentContribsUtil/fetchAllRecentMonthContribs.js @@ -14,6 +14,8 @@ function fetchAllRecentMonthContribs(org, repos, queryTime) { .then(function gotResponse(response) { if(response.status=="200") { return response.json(); + }else { + throw `Couldn't fetch recent contributors for ${repo}`; } }) .then(function gotResponseJson(response) { @@ -35,7 +37,10 @@ function fetchAllRecentMonthContribs(org, repos, queryTime) { model_utils.setItem(`recent-${repo}-month-expiry`, currTime); } return true; - }); + }) + .catch((err) => { + throw err; + }) }); return Promise.all(promises) diff --git a/src/utils/recentContribsUtil/fetchRecentMonthContribs.js b/src/utils/recentContribsUtil/fetchRecentMonthContribs.js index 489b4acc..adbb7725 100644 --- a/src/utils/recentContribsUtil/fetchRecentMonthContribs.js +++ b/src/utils/recentContribsUtil/fetchRecentMonthContribs.js @@ -8,6 +8,8 @@ function fetchRecentMonthContribs(org, repo, queryTime) { .then(function gotResponse(response) { if(response.status=="200") { return response.json(); + }else { + throw `Couldn't fetch recent contributors for ${repo}`; } }) .then(function gotResponseJson(response) { @@ -28,7 +30,11 @@ function fetchRecentMonthContribs(org, repo, queryTime) { model_utils.setItem(`recent-${repo}-month-expiry`, currTime); } return result; - }); + }) + .catch((err) => { + console.log("throwing from fetchRecentMonthContribs"); + throw err; + }) } diff --git a/src/utils/recentContribsUtil/getContribsLastMonth.js b/src/utils/recentContribsUtil/getContribsLastMonth.js index a2d95339..80f9e2a5 100644 --- a/src/utils/recentContribsUtil/getContribsLastMonth.js +++ b/src/utils/recentContribsUtil/getContribsLastMonth.js @@ -5,7 +5,8 @@ let fetchRecentMonthContribs = require('./fetchRecentMonthContribs') // Fetches recent month's commits for a particular repo or all of the repos (10 repos) function getContribsLastMonth(org, repo) { - return model_utils.getItem('repos').then((repos) => { + return model_utils.getItem('repos') + .then((repos) => { if(repos!=null && repos!=undefined) { return model_utils.getItem(`recent-${repo}-month-expiry`) .then((recentCommitsMonthExpiry) => { @@ -32,18 +33,30 @@ function getContribsLastMonth(org, repo) { if(repo==='all') { return fetchAllRecentMonthContribs.fetchAllRecentMonthContribs(org, repos, queryTime) .then(function gotRecentCommitsInStorage(month_commits) { - return month_commits; - }); + return month_commits; + }) + .catch((err) => { + console.log("throwing from getContribsLastMonth"); + throw err; + }) } else { return fetchRecentMonthContribs.fetchRecentMonthContribs(org, repo, queryTime) .then(function gotRecentCommitsInStorage(month_commits) { - return month_commits; - }) + return month_commits; + }) + .catch((err) => { + console.log("throwing from getContribsLastMonth"); + throw err; + }) } } }) }) + .catch((err) => { + console.log("finally throwing from getContribsLastMonth"); + throw err; + }); } else { console.log("repos are not there yet!!!"); } diff --git a/src/utils/recentContribsUtil/main.js b/src/utils/recentContribsUtil/main.js index ef949b81..669214a5 100644 --- a/src/utils/recentContribsUtil/main.js +++ b/src/utils/recentContribsUtil/main.js @@ -9,6 +9,10 @@ function fetchContribsLastMonth(org, repo) { .then((contribs) => { return contribs; }) + .catch((err) => { + console.log("finally throwing"); + throw err; + }) } function fetchContribsLastWeek(org, repo) { @@ -16,6 +20,10 @@ function fetchContribsLastWeek(org, repo) { .then((contribs) => { return contribs; }) + .catch((err) => { + console.log("finally throwing"); + throw err; + }) } function fetchAllRecentContribsInDb(org, repo) { @@ -23,6 +31,10 @@ function fetchAllRecentContribsInDb(org, repo) { .then((response) => { return response; }) + .catch((err) => { + console.log("finally throwing"); + throw err; + }) } diff --git a/src/utils/recentContribsUtil/storeAllRecentContribsInDb.js b/src/utils/recentContribsUtil/storeAllRecentContribsInDb.js index 4d4ab7d7..5122b966 100644 --- a/src/utils/recentContribsUtil/storeAllRecentContribsInDb.js +++ b/src/utils/recentContribsUtil/storeAllRecentContribsInDb.js @@ -9,7 +9,8 @@ function storeAllRecentContribsInDb(org, repo) { let d = (new Date); d.setDate(d.getDate() - 30); let queryTime = d.toISOString(); - return model_utils.getItem('repos').then((repos) => { + return model_utils.getItem('repos') + .then((repos) => { return model_utils.getItem('recent-present').then((result)=> { if(result!=null && result!=undefined) { return result; @@ -19,22 +20,32 @@ function storeAllRecentContribsInDb(org, repo) { return fetchAllRecentMonthContribs.fetchAllRecentMonthContribs(org, repos, queryTime) .then((result) => { model_utils.setItem('recent-present', 'true'); - return result; - }) + return result; + }) + .catch((err) => { + throw err; + }) } else { - fetchRepoUtil.getAllRepos(org).then((repos) => { - if(repos!=null || repos!=undefined) { - return fetchAllRecentMonthContribs.fetchAllRecentMonthContribs(org, repos, queryTime) - .then((result) => { - model_utils.setItem('recent-present', 'true'); - return result; - }) - } - }); + fetchRepoUtil.getAllRepos(org) + .then((repos) => { + if(repos!=null || repos!=undefined) { + return fetchAllRecentMonthContribs.fetchAllRecentMonthContribs(org, repos, queryTime) + .then((result) => { + model_utils.setItem('recent-present', 'true'); + return result; + }) + .catch((err) => { + throw err; + }) + } + }); } - } + } }); }) + .catch((err) => { + throw err; + }) } diff --git a/src/utils/repoUtil/fetchRepoUtil.js b/src/utils/repoUtil/fetchRepoUtil.js index 252c2e71..a858f9aa 100644 --- a/src/utils/repoUtil/fetchRepoUtil.js +++ b/src/utils/repoUtil/fetchRepoUtil.js @@ -10,6 +10,8 @@ function getAllRepos(org) { .then(function gotRepos(data) { if(data.status=='200') { return data.json(); + }else { + throw "Couldn't fetch repositories :("; } }) .then(function mapToEachRepo(results) { @@ -23,6 +25,9 @@ function getAllRepos(org) { model_utils.setItem('repos', repos); return(repos); }) + .catch((err) => { + throw err; + }) } diff --git a/src/utils/staleIssuesUtil.js b/src/utils/staleIssuesUtil.js index 744de693..f6914ba9 100644 --- a/src/utils/staleIssuesUtil.js +++ b/src/utils/staleIssuesUtil.js @@ -14,30 +14,35 @@ function getOrgWideIssues(org) { }) .then(() => { return model_utils.getItem("staleIssues").then((issues) => { - let pages = 5; // we take 2 to stay under API limit + let pages = 5; // we take 5 to stay under API limit if(issues!=undefined && issues!=null) { return issues; } for(let i=1;i<=pages;i++) { let curr = fetch(`https://api.github.com/search/issues?q=is%3Aopen+org%3A${org}+page%3A${i}`) - .then((data) => { - if(data.status=='200') { - return data.json(); - } - }) - .then(function (data) { - if(data!=null && data!=undefined) { - data.items.map(function mappingToIssues(issue, index) { - let dateLastUpdated = new Date(`${issue.updated_at}`); - let lastDate = dateLastUpdated.getTime(); - let today = (new Date).getTime(); - if(Math.ceil(Math.abs(today - lastDate) / (1000*3600*24)) > 10 ) { - staleIssues.push(issue); - } - }) - } - }) + .then((data) => { + if(data.status=='200') { + return data.json(); + }else { + throw "Couldn't fetch issues"; + } + }) + .then(function (data) { + if(data!=null && data!=undefined) { + data.items.map(function mappingToIssues(issue, index) { + let dateLastUpdated = new Date(`${issue.updated_at}`); + let lastDate = dateLastUpdated.getTime(); + let today = (new Date).getTime(); + if(Math.ceil(Math.abs(today - lastDate) / (1000*3600*24)) > 10 ) { + staleIssues.push(issue); + } + }) + } + }) + .catch((err) => { + throw err; + }) totalPromises.push(curr); @@ -51,16 +56,23 @@ function getOrgWideIssues(org) { }) }) }) + .catch((err) => { + throw err; + }) } function getStaleIssues(org, repo) { - return getOrgWideIssues(org, repo).then((issues) => { + return getOrgWideIssues(org, repo) + .then((issues) => { if(issues!=undefined && issues!=null) { return issues; } }) + .catch((err) => { + throw err; + }) }