-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpredict.js
31 lines (30 loc) · 883 Bytes
/
predict.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
* This file predicts the time the user will work for based on
* their past activity.
* Implemented using OLS.
*/
export class Predict {
constructor() {
this.hours = [];
}
gather_data(){
// collect data into (x:day_number, y:hours_worked) tuple
var Y = [];
chrome.storage.sync.get("zen_daily_metrics", zen_data => {
zen_data = zen_data.zen_daily_metrics;
if (zen_data && zen_data.timeline) {
Object.keys(zen_data.timeline).map(function (key) {
let f = parseFloat(zen_data.timeline[key] / 3600).toPrecision(3);
Y.push(parseFloat(f)); //get number of hours
});
console.log(Y);
}
console.log(Y);
this.hours = Y;
});
}
get_data()
{
return this.hours;
}
}