Skip to content

Commit

Permalink
added TODO:OnlyOneCal, since only 1 cal entry is loaded we can't igno…
Browse files Browse the repository at this point in the history
…re future data
  • Loading branch information
jasoncalabrese committed Jul 7, 2015
1 parent 09ea5c5 commit 5bd5fac
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/data.js
Expand Up @@ -81,6 +81,7 @@ function init(env, ctx) {
});
}, cal: function (callback) {
//FIXME: date $gte?????
//TODO:OnlyOneCal - currently we only load the last cal
var cq = {count: 1, find: {type: 'cal'}};
ctx.entries.list(cq, function (err, results) {
if (!err && results) {
Expand Down
4 changes: 3 additions & 1 deletion lib/plugins/ar2.js
Expand Up @@ -76,7 +76,9 @@ function init() {
var rawSGVs;

if (sbx.properties.rawbg && sbx.extendedSettings.useRaw) {
var cal = sbx.lastEntry(sbx.data.cals);

//TODO:OnlyOneCal - currently we only load the last cal, so we can't ignore future data
var cal = _.last(sbx.data.cals);
if (cal) {
rawSGVs = _.map(_.takeRight(sgvs, 2), function eachSGV(sgv) {
var rawResult = rawbg.calc(sgv, cal);
Expand Down
6 changes: 5 additions & 1 deletion lib/plugins/rawbg.js
@@ -1,5 +1,7 @@
'use strict';

var _ = require('lodash');

function init() {

function rawbg() {
Expand All @@ -14,7 +16,9 @@ function init() {
sbx.offerProperty('rawbg', function setRawBG ( ) {
var result = { };
var currentSGV = sbx.lastSGVEntry();
var currentCal = sbx.lastEntry(sbx.data.cals);

//TODO:OnlyOneCal - currently we only load the last cal, so we can't ignore future data
var currentCal = _.last(sbx.data.cals);

if (currentSGV && currentCal) {
result.value = rawbg.calc(currentSGV, currentCal, sbx);
Expand Down

0 comments on commit 5bd5fac

Please sign in to comment.