Skip to content

Commit 53aff0e

Browse files
authored
Merge pull request #295 from LLNL/activityGraphFix
Filter out incomplete activity datapoints
2 parents 5d939da + 48d7620 commit 53aff0e

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

js/explore/line_repoActivity.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,9 @@ function draw_line_repoActivity(areaID, repoNameWOwner) {
187187
function reformatData(obj) {
188188
// Calculate combined values
189189
var dataTotals = {};
190+
var repoCounts = {};
190191
var repos = repoNameWOwner == null ? Object.keys(obj['data']) : [repoNameWOwner];
192+
var numReposExpected = repos.length;
191193
repos.forEach(function(repo) {
192194
if (obj['data'].hasOwnProperty(repo)) {
193195
var weeklyNodes = obj['data'][repo];
@@ -196,25 +198,34 @@ function draw_line_repoActivity(areaID, repoNameWOwner) {
196198
var weeklytotal = weeklyNodes[i]['total'];
197199
if (!Object.keys(dataTotals).contains(weekstamp)) {
198200
dataTotals[weekstamp] = 0;
201+
repoCounts[weekstamp] = 0;
199202
}
200203
dataTotals[weekstamp] += weeklytotal;
204+
repoCounts[weekstamp] += 1;
201205
}
202206
} else {
203207
console.log('No activity data recorded for ' + repo + ', using dummy data.');
204208
// Today
205209
var end = new Date();
206210
dataTotals[formatTime(end)] = 0;
211+
repoCounts[formatTime(end)] = 1;
207212
// Tomorrow, 1 year ago
208213
var start = new Date(new Date().getFullYear() - 1, new Date().getMonth(), new Date().getDate() + 1);
209214
dataTotals[formatTime(start)] = 0;
215+
repoCounts[formatTime(start)] = 1;
210216
}
211217
});
212218

213-
// Formate data for graphing
219+
// Format data for graphing
214220
var data = [];
215221
var sortedTimestamps = Object.keys(dataTotals).sort();
216222
sortedTimestamps.forEach(function(timestamp) {
217-
data.push({ date: timestamp, value: dataTotals[timestamp] });
223+
var numReposFound = repoCounts[timestamp];
224+
if (numReposFound == numReposExpected) {
225+
data.push({ date: timestamp, value: dataTotals[timestamp] });
226+
} else {
227+
console.log('Repo count mismatch for activity on ' + timestamp + ': expected ' + numReposExpected + ', found ' + numReposFound);
228+
}
218229
});
219230

220231
return data;

0 commit comments

Comments
 (0)