-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Gunvor Nilsson
committed
Aug 22, 2019
1 parent
50e6340
commit 3e0f36e
Showing
6 changed files
with
109 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module.exports = (function () { | ||
function addHeat(temp) { | ||
let check = false; | ||
|
||
for (let i = 0; i < temp.length; i++) { | ||
if (temp[i] === 1 && check === false) { | ||
if (i > 0) {temp[i-1] = 2;} | ||
if (i > 1) {temp[i-2] = 2;} | ||
check = true; | ||
} | ||
if (check === true && temp[i] === 0) { | ||
check = false; | ||
} | ||
} | ||
return temp; | ||
} | ||
|
||
return { | ||
addHeat: addHeat | ||
}; | ||
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const ish = require('./isHigh'); | ||
|
||
module.exports = (function () { | ||
function hourList(data, marker, avg) { | ||
let temp = []; | ||
|
||
for (let i = 1; i < 26; i++) { | ||
let key = i < 3 ? 'Hour' + i : 'Hour' + (i-1); | ||
|
||
if (i === 3) { | ||
key = 'Hour' + i + 'A'; | ||
temp = ish.isHigh(temp, data, key, marker, avg); | ||
} else if (i === 4) { | ||
key = 'Hour' + (i-1) + 'B'; | ||
temp = ish.isHigh(temp, data, key, marker, avg); | ||
} else { | ||
temp = ish.isHigh(temp, data, key, marker, avg); | ||
} | ||
} | ||
return temp; | ||
} | ||
|
||
return { | ||
hourList: hourList | ||
}; | ||
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module.exports = (function () { | ||
function isHigh(list, data, key, marker, avg) { | ||
let tl = list; | ||
let price = data[key] === "" ? null : parseFloat(data[key]) / 10; | ||
|
||
if (price && ((price * marker) > avg)) { | ||
tl.push(1); | ||
} else if (price) { | ||
tl.push(0); | ||
} | ||
return tl; | ||
} | ||
|
||
return { | ||
isHigh: isHigh | ||
}; | ||
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters