codacy clean up

This commit is contained in:
Jason Calabrese
2016-11-04 01:31:18 -07:00
parent 57b3c6cc6d
commit b7f1257c3e
3 changed files with 23 additions and 30 deletions
+2 -3
View File
@@ -29,15 +29,14 @@ function boot (env, language) {
}
if(configURL && href) {
var request = require('request');
console.log('Getting', href);
console.log('Getting settings from', href);
request.get({url: href, json: true}, function (err, resp, body) {
console.log("GOT", body);
if (err) {
console.log('Attempt to fetch config', href, 'failed.');
console.error(err);
throw err;
} else {
console.log('extending');
console.log('extending settings with', body);
_.merge(env.settings, body);
}
next( );
+1 -9
View File
@@ -9,18 +9,12 @@ function get_time_spec (spec) {
return date(spec);
}
function get_context (req, res, next) {
res.data = req.ctx;
// res.send(req.ctx.ddata);
next( );
}
function ddata_at (at, ctx, callback) {
var ddata = ctx.ddata.clone( );
if (Math.abs(at - ddata.lastUpdated) < 1000 * 60 * 5) {
return callback(null, ctx.ddata);
}
ctx.dataloader.update(ddata, {lastUpdated: at, frame: true}, function (err, result) {
ctx.dataloader.update(ddata, {lastUpdated: at, frame: true}, function (err) {
// console.log('results', err, result);
// console.log('ddata', ddata);
callback(err, ddata);
@@ -73,9 +67,7 @@ function configure (app, ctx) {
next( );
});
// api.get('/ctx/:at', get_context, format_result);
api.get('/at/:at?', ensure_at, get_ddata, format_result);
// '/count/:store/
return api;
}
+20 -18
View File
@@ -39,21 +39,23 @@ window.Nightscout.client.init(function loaded() {
function createLoop (synth, sgvs) {
function callback (time, note) {
console.log(time, note);
synth.triggerAttackRelease(note, "16n", time);
synth.triggerAttackRelease(note, '16n', time);
}
var seq = new Tone.Sequence(callback, sgvs, "16n");
var seq = new Tone.Sequence(callback, sgvs, '16n');
seq.loop = false;
return seq;
}
function glucose (sgv) {
if (sgv)
return parseInt(sgv.mgdl || sgv.sgv || sgv.glucose || 35)
return 20
if (sgv) {
return parseInt(sgv.mgdl || sgv.sgv || sgv.glucose || 35);
}
return 20;
}
$(document).ready(function ( ) {
console.log("OK");
console.log('OK');
var converter = convert( );
var synth = new Tone.PolySynth(16, Tone.MonoSynth);
// default volume always makes my ears bleed
@@ -62,19 +64,19 @@ window.Nightscout.client.init(function loaded() {
Tone.Transport.timeSignature = [ 3, 2 ];
Tone.Transport.bpm.value = 320;
function play_next (time) {
var sgv = sgvs.shift( );
console.log(sgv);
if (!sgv) {
loop.stop( );
}
if (sgv) {
var freq = converter.freq(sgv.mgdl || 30);
synth.triggerAttackRelease(parseInt(sgv.mgdl || sgv.sgv || sgv.glucose || 39) * 4, "8n", time);
}
}
// function play_next (time) {
// var sgv = sgvs.shift( );
// console.log(sgv);
// if (!sgv) {
// loop.stop( );
// }
// if (sgv) {
// var freq = converter.freq(sgv.mgdl || 30);
// synth.triggerAttackRelease(parseInt(sgv.mgdl || sgv.sgv || sgv.glucose || 39) * 4, '8n', time);
// }
// }
// var loop = new Tone.Loop(play_next, "4n");
// var loop = new Tone.Loop(play_next, '4n');
var loop;
function play_data ( ) {
var sgvs = Nightscout.client.sbx.data.sgvs.slice( ).map(glucose).map(converter.freq);