Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Commit

Permalink
Fix bug createing client-side CoP when no feeds
Browse files Browse the repository at this point in the history
  • Loading branch information
MyForest committed Mar 5, 2020
1 parent 19426b1 commit bc13e4d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Lib/charts.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function sum(arrayOfNumber) {
return arrayOfNumber.reduce((p, value) => p + value || 0, 0)
}
function createCoPFeed(inputFeedHistory, outputFeedHistory) {
if (inputFeedHistory == null || outputFeedHistory == null) return []

// Assumes the feeds are aligned in time and there's no gaps in either feed
return inputFeedHistory.map((row, index, array) => {
Expand All @@ -35,7 +36,9 @@ function createCoPFeed(inputFeedHistory, outputFeedHistory) {
if (row[1] == 0) return null;

// If no output then don't declare a CoP
if (outputFeedHistory[index][1] == 0) return null;
if (outputFeedHistory[index]) {
if (outputFeedHistory[index][1] == 0) return null;
}

const cohortSize = Math.min(index, 3)

Expand Down

0 comments on commit bc13e4d

Please sign in to comment.