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

Wip/bewest/daytoday redo 02 #7849

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
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
8 changes: 6 additions & 2 deletions lib/report/reportclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,13 @@ var init = function init () {
function datefilter () {
if ($('#rp_enabledate').is(':checked')) {
matchesneeded++;
var from = moment.tz($('#rp_from').val().replace(/\//g, '-') + 'T00:00:00', zone);
var to = moment.tz($('#rp_to').val().replace(/\//g, '-') + 'T23:59:59', zone);
var from = moment.tz(moment($('#rp_from').val()).startOf('day'), zone).startOf('day');
var to = moment.tz(moment($('#rp_to').val()).startOf('day'), zone).endOf('day');
timerange = '&find[created_at][$gte]=' + from.toISOString() + '&find[created_at][$lt]=' + to.toISOString();

console.log('DATEFILTER', zone, timerange);
console.log("DATEFILTER", "FROM", from.format( ), moment.tz(moment($('#rp_from').val()).startOf('day'), zone).format( ) );
console.log("DATEFILTER", "TO", to.format( ), moment.tz(moment($('#rp_to').val()).startOf('day'), zone).endOf('day').format( ) );
//console.log($('#rp_from').val(),$('#rp_to').val(),zone,timerange);
while (from <= to) {
if (daystoshow[from.format('YYYY-MM-DD')]) {
Expand Down
6 changes: 3 additions & 3 deletions lib/report_plugins/daytoday.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ daytoday.report = function report_daytoday (datastorage, sorteddaystoshow, optio
// create svg and g to contain the chart contents
charts = d3.select('#daytodaychart-' + day).html(
'<b>' +
report_plugins.utils.localeDate(day) +
report_plugins.utils.localeDate(moment(day)) +
'</b><br>'
).append('svg');

Expand Down Expand Up @@ -432,8 +432,8 @@ daytoday.report = function report_daytoday (datastorage, sorteddaystoshow, optio
contextCircles.exit()
.remove();

var to = moment(day).add(1, 'days');
var from = moment(day);
var from = moment.tz(day, profile.getTimezone( )).startOf('day');
var to = moment(from.clone( )).add(1, 'days');
var iobpolyline = ''
, cobpolyline = '';

Expand Down
3,841 changes: 2,354 additions & 1,487 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"errorhandler": "^1.5.1",
"event-stream": "3.3.4",
"expose-loader": "^2.0.0",
"express": "^4.18.2",
"express": "4.17.1",
"express-minify": "^1.0.0",
"fast-password-entropy": "^1.1.1",
"file-loader": "^6.2.0",
Expand All @@ -105,7 +105,7 @@
"jquery.tooltips": "^1.0.0",
"js-storage": "^1.1.0",
"jsdom": "^11.11.0",
"jsonwebtoken": "^9.0.0",
"jsonwebtoken": "^8.5.1",
"lodash": "^4.17.20",
"memory-cache": "^0.2.0",
"mime": "^2.4.6",
Expand Down
6 changes: 2 additions & 4 deletions tests/fixtures/headless.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ function headless (benv, binding) {
, serverSettings: serverSettings
, localCookieStorage: self.localStorage
, cookieStorageType: self.localStorage
, localStorage: self.localStorage
, localStorage: self.localStorage
, io: {
connect: function mockConnect ( ) {
return {
Expand All @@ -170,9 +170,7 @@ function headless (benv, binding) {
benv.require(req);
});
callback( );
},
{url: 'http://localhost/'}
);
});

}

Expand Down
14 changes: 5 additions & 9 deletions tests/hashauth.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ require('should');
var benv = require('benv');
var read = require('fs').readFileSync;
var serverSettings = require('./fixtures/default-server-settings');
let localStorage = require('./fixtures/localstorage');

describe('hashauth', function ( ) {
this.timeout(50000); // TODO: see why this test takes longer on Travis to complete

var self = this;
benv.localStorage = localStorage;

var headless = require('./fixtures/headless')(benv, this);

before(function (done) {
Expand Down Expand Up @@ -67,7 +64,7 @@ describe('hashauth', function ( ) {
benv.teardown();
done();
});
*/
*/

it ('should make module unauthorized', function () {
var client = require('../lib/client');
Expand Down Expand Up @@ -106,7 +103,7 @@ describe('hashauth', function ( ) {
it ('should store hash and the remove authentication', function () {
var client = require('../lib/client');
var hashauth = require('../lib/client/hashauth');
//var localStorage = require('./fixtures/localstorage');
var localStorage = require('./fixtures/localstorage');

localStorage.remove('apisecrethash');

Expand All @@ -122,8 +119,7 @@ describe('hashauth', function ( ) {
hashauth.processSecret('this is my long pass phrase',true);

hashauth.hash().should.equal('b723e97aa97846eb92d5264f084b2823f57c4aa1');

window.localStorage.getItem('apisecrethash').should.equal('b723e97aa97846eb92d5264f084b2823f57c4aa1');
localStorage.get('apisecrethash').should.equal('b723e97aa97846eb92d5264f084b2823f57c4aa1');
hashauth.isAuthenticated().should.equal(true);

hashauth.removeAuthentication();
Expand All @@ -133,7 +129,7 @@ describe('hashauth', function ( ) {
it ('should not store hash', function () {
var client = require('../lib/client');
var hashauth = require('../lib/client/hashauth');
//var localStorage = require('./fixtures/localstorage');
var localStorage = require('./fixtures/localstorage');

localStorage.remove('apisecrethash');

Expand All @@ -156,7 +152,7 @@ describe('hashauth', function ( ) {
it ('should report secret too short', function () {
var client = require('../lib/client');
var hashauth = require('../lib/client/hashauth');
//var localStorage = require('./fixtures/localstorage');
var localStorage = require('./fixtures/localstorage');

localStorage.remove('apisecrethash');

Expand Down
6 changes: 3 additions & 3 deletions tests/reports.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var someData = {
'/api/v1/treatments.json?find[created_at][$gte]=2015-08-14T00:00:00.000Z&find[created_at][$lt]=2015-08-15T00:00:00.000Z&count=1000': [{'enteredBy':'Dad','eventType':'Site Change','glucose':268,'glucoseType':'Finger','insulin':1.75,'units':'mg/dl','created_at':'2015-08-14T00:00:00.000Z','_id':'55ce78fe925aa80e7071e5d6'},{'enteredBy':'Mom ','eventType':'Meal Bolus','glucose':89,'glucoseType':'Finger','carbs':54,'insulin':3.15,'units':'mg/dl','created_at':'2015-08-14T21:00:00.000Z','_id':'55ce59bb925aa80e7071e5ba'}],
'/api/v1/entries.json?find[date][$gte]=1439596800000&find[date][$lt]=1439683200000&count=10000': [{'_id':'55cfd25f38a8d88ad1b49931','unfiltered':283136,'filtered':304768,'direction':'SingleDown','device':'dexcom','rssi':185,'sgv':306,'dateString':'Sat Aug 15 16:58:16 PDT 2015','type':'sgv','date':1439683096000,'noise':1},{'_id':'55cfd13338a8d88ad1b4992e','unfiltered':302528,'filtered':312576,'direction':'FortyFiveDown','device':'dexcom','rssi':179,'sgv':329,'dateString':'Sat Aug 15 16:53:16 PDT 2015','type':'sgv','date':1439682796000,'noise':1}],
'/api/v1/food/regular.json': [{'_id':'552ece84a6947ea011db35bb','type':'food','category':'Zakladni','subcategory':'Sladkosti','name':'Bebe male','portion':18,'carbs':12,'gi':1,'unit':'pcs','created_at':'2015-04-15T20:48:04.966Z'}],
'/api/v1/treatments.json?find[eventType]=/BG Check/i&find[created_at][$gte]=2015-08-08T00:00:00.000Z&find[created_at][$lt]=2015-09-07T23:59:59.000Z': [
'/api/v1/treatments.json?find[eventType]=/BG Check/i&find[created_at][$gte]=2015-08-08T00:00:00.000Z&find[created_at][$lt]=2015-09-07T23:59:59.999Z': [
{'created_at':'2015-08-08T00:00:00.000Z'},
{'created_at':'2015-08-09T00:00:00.000Z'},
{'created_at':'2015-08-10T00:00:00.000Z'},
Expand Down Expand Up @@ -63,7 +63,7 @@ var someData = {
{'created_at':'2015-09-06T00:00:00.000Z'},
{'created_at':'2015-09-07T00:00:00.000Z'}
],
'/api/v1/treatments.json?find[notes]=/something/i&find[created_at][$gte]=2015-08-08T00:00:00.000Z&find[created_at][$lt]=2015-09-07T23:59:59.000Z': [
'/api/v1/treatments.json?find[notes]=/something/i&find[created_at][$gte]=2015-08-08T00:00:00.000Z&find[created_at][$lt]=2015-09-07T23:59:59.999Z': [
{'created_at':'2015-08-08T00:00:00.000Z'},
{'created_at':'2015-08-09T00:00:00.000Z'},
{'created_at':'2015-08-10T00:00:00.000Z'},
Expand Down Expand Up @@ -96,7 +96,7 @@ var someData = {
{'created_at':'2015-09-06T00:00:00.000Z'},
{'created_at':'2015-09-07T00:00:00.000Z'}
],
'/api/v1/devicestatus.json&find[created_at][$gte]=2015-08-08T00:00:00.000Z&find[created_at][$lt]=2015-09-07T23:59:59.000Z?find[openaps][$exists]=true&count=1000': [
'/api/v1/devicestatus.json&find[created_at][$gte]=2015-08-08T00:00:00.000Z&find[created_at][$lt]=2015-09-07T23:59:59.999Z?find[openaps][$exists]=true&count=1000': [
{
'openaps': {
'suggested': {
Expand Down