From c0f6b2245cfd18d715905876df693d100e8c37c5 Mon Sep 17 00:00:00 2001 From: peterleimbach Date: Mon, 3 Feb 2020 08:09:43 +0100 Subject: [PATCH] =?UTF-8?q?Added=20period=20of=20days=20into=20headline=20?= =?UTF-8?q?of=20glucose=20distribution=20and=20percen=E2=80=A6=20(#5428)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added period of days into headline of glucose distribution and percentil chart report I make screencopies of the glucose distribution and percential chart report for my diabtes consultant and had to manually add the period of days to the report everytime because it was not shown in the report itself. I added the period of days this with a small number of lines of code and think this is helpful for other too. * removed comments as requested removed comments as requested * Camelcase for new variables reportPlugins, firstDay, lastDay, countDays * forget to save the change of reportPlugins in percentile.js --- lib/report_plugins/glucosedistribution.js | 12 ++++++--- lib/report_plugins/percentile.js | 31 ++++++++++++++++------- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/lib/report_plugins/glucosedistribution.js b/lib/report_plugins/glucosedistribution.js index f97bd034765..21d5213e9c9 100644 --- a/lib/report_plugins/glucosedistribution.js +++ b/lib/report_plugins/glucosedistribution.js @@ -19,9 +19,9 @@ glucosedistribution.html = function html (client) { var ret = '

' + translate('Glucose distribution') + - ' (' + - ' ' + - ' )' + + ' (' + + '' + + ')' + '

' + '' + '' + @@ -122,7 +122,11 @@ glucosedistribution.report = function report_glucosedistribution (datastorage, s var data = datastorage.allstatsrecords; var days = datastorage.alldays; - $('#glucosedistribution-days').text(days + ' ' + translate('days total')); + var reportPlugins = Nightscout.report_plugins; + var firstDay = reportPlugins.utils.localeDate(sorteddaystoshow[sorteddaystoshow.length - 1]); + var lastDay = reportPlugins.utils.localeDate(sorteddaystoshow[0]); + + $('#glucosedistribution-days').text(days + ' ' + translate('days total') + ', ' + firstDay + ' - ' + lastDay); for (var i = 0; i < 24; i++) { $('#glucosedistribution-' + i).unbind('click').click(onClick); diff --git a/lib/report_plugins/percentile.js b/lib/report_plugins/percentile.js index 803860d5e47..9694fd51faf 100644 --- a/lib/report_plugins/percentile.js +++ b/lib/report_plugins/percentile.js @@ -15,11 +15,17 @@ module.exports = init; percentile.html = function html(client) { var translate = client.translate; var ret = - '

' + translate('Glucose Percentile report') + '

' - + '
' - + '
' - + '
' - ; + '

' + + translate('Glucose Percentile report') + + ' (' + + '' + + ')' + + '

' + + '
' + + '
' + + '
' + ; + return ret; }; @@ -36,16 +42,23 @@ percentile.report = function report_percentile(datastorage, sorteddaystoshow, op var translate = client.translate; var ss = require('simple-statistics'); - var minutewindow = 30; //minute-window should be a divisor of 60 - + var minutewindow = 30; //minute-window should be a divisor of 60 + var data = datastorage.allstatsrecords; - + var bins = []; var filterFunc = function withinWindow(record) { var recdate = new Date(record.displayTime); return recdate.getHours() === hour && recdate.getMinutes() >= minute && recdate.getMinutes() < minute + minutewindow; }; - + + var reportPlugins = Nightscout.report_plugins; + var firstDay = reportPlugins.utils.localeDate(sorteddaystoshow[sorteddaystoshow.length - 1]); + var lastDay = reportPlugins.utils.localeDate(sorteddaystoshow[0]); + var countDays = sorteddaystoshow.length; + + $('#percentile-days').text(countDays + ' ' + translate('days total') + ', ' + firstDay + ' - ' + lastDay); + for (var hour = 0; hour < 24; hour++) { for (var minute = 0; minute < 60; minute = minute + minutewindow) { var date = new Date();