Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test adding arrows for @jwedding #5

Merged
merged 1 commit into from
Jun 2, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion lib/pebble.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
var DIRECTIONS = {
NONE: 0
, DoupleUp: 1
, SingleUp: 2
, FortyFiveUp: 3
, Flat: 4
, FortyFiveDown: 5
, SingleDown: 6
, DoubleDown: 7
, 'NOT COMPUTABLE': 8
, 'RATE OUT OF RANGE': 9
};

function directionToTrend (direction) {
var trend = 8;
if (direction in DIRECTIONS) {
trend = DIRECTIONS[direction];
}
return trend;
}

function pebble (req, res) {
var FORTY_MINUTES = 2400000;
Expand All @@ -16,7 +36,10 @@ function pebble (req, res) {
var obj = {};
obj.sgv = element.sgv;
obj.bgdelta = (last ? (last.sgv - element.sgv) : 0);
obj.trend = 0;
if ('direction' in element) {
obj.trend = directionToTrend(element.direction);
obj.direction = element.direction;
}
// obj.y = element.sgv;
// obj.x = element.date;
obj.datetime = element.date;
Expand Down