Skip to content

Commit

Permalink
Use repo.open_issues_count to make the existing warning about unfetch…
Browse files Browse the repository at this point in the history
…ed data be a bit more informative (thank you to @gordongli for the suggestion in #71, and this should go some way towards fixing that)
  • Loading branch information
stuartlangridge committed Feb 16, 2018
1 parent 2967c47 commit 8a2d0b8
Showing 1 changed file with 53 additions and 4 deletions.
57 changes: 53 additions & 4 deletions lib/checking.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,61 @@ function confirmCrawler(options) {
Confirm that there are at least some issues for each repo in your
config. If not, show a warning.
*/
var open_issues_expected_per_repo = {};
repos.forEach(function(r) {
open_issues_expected_per_repo[r.full_name.toLowerCase()] = r.open_issues_count;
})
async.eachLimit(options.userConfig.github_repositories, 5, function(repo_name, done) {
issue.find({html_url: { $regex: new RegExp(repo_name), $options: 'i' }}).sort({updated_at:-1}).limit(1).toArray().then(iss => {
if (iss.length == 0) {
var warning = "WARNING: there are no issues recorded for the " +
repo_name + " repository. This may just be because we haven't " +
"fetched that data yet.";
var fetched_issue_count = iss.length,
fetched_open_issue_count = 0,
fetched_closed_issue_count = 0;
var expected_open_issue_count = open_issues_expected_per_repo[repo_name.toLowerCase()];
iss.forEach(function(i) {
if (i.closed_at) {
fetched_closed_issue_count += 1;
} else {
fetched_open_issue_count += 1;
}
});

/* we now know:
how many open issues github thinks this repo has (expected_open_issue_count)
how many open issues we actually have data for (fetched_open_issue_count)
how many issues in total we actually have data for (fetched_issue_count)
Some or all of these figures may be out of date, if we're in the process
of fetching data, of course. But they give us some indication of how
to warn the user. */

var warning;
if (fetched_issue_count === 0) {
// We don't have any data in our DB about issues for this repo
if (fetched_open_issue_count === 0) {
// and we're not expecting there to be any *open* issues.
// It's possible that there are closed issues which remain
// unfetched, so we can't assume we're up to date, but the
// message can be somewhat conciliatory.
warning = "WARNING: there are no issues in our database for the " +
repo_name + " repository. It's quite likely that this is because " +
"there actually aren't any, but it's possible that there are closed " +
"issues which we are still in the process of fetching data for.";
} else {
warning = "WARNING: there are no issues recorded for the " +
repo_name + " repository. This is very likely because we are still " +
"in the process of fetching that data. Dashboards may be inaccurate " +
"until the data fetch is complete and they are regenerated.";
}
} else {
if (fetched_open_issue_count < expected_open_issue_count) {
warning = "WARNING: there are fewer open issues in our database for the " +
repo_name + " repository than we expect. This is very likely because " +
"we are still in the process of fetching that data. Dashboards " +
"may be inaccurate until the data fetch is complete and " +
"they are regenerated.";
}
}

if (warning) {
console.warn(wrap(warning, {width: 65}));
}
done();
Expand Down

0 comments on commit 8a2d0b8

Please sign in to comment.