Correct 7-day average calculations on Welcome page.

This commit is contained in:
Seeker4 2019-07-31 10:31:08 -07:00
parent 3b1414c37d
commit c602fa7dcb

View File

@ -198,11 +198,12 @@ QString Welcome::GenerateCPAPHTML()
int averagedays = 7; // how many days to look back int averagedays = 7; // how many days to look back
QDate starttime = date.addDays(-(averagedays-1)); QDate starttime = date.addDays(-averagedays);
QDate endtime = date.addDays(-1);
EventDataType ahi = (day->count(CPAP_Obstructive) + day->count(CPAP_Hypopnea) + day->count(CPAP_ClearAirway) + day->count(CPAP_Apnea)) / hours; EventDataType ahi = (day->count(CPAP_Obstructive) + day->count(CPAP_Hypopnea) + day->count(CPAP_ClearAirway) + day->count(CPAP_Apnea)) / hours;
EventDataType ahidays = calcAHI(starttime, date); EventDataType ahidays = calcAHI(starttime, endtime);
const QString under = tr("under"); const QString under = tr("under");
const QString over = tr("over"); const QString over = tr("over");
@ -261,7 +262,7 @@ QString Welcome::GenerateCPAPHTML()
//EventDataType leaks = 1.0/hours * lat; //EventDataType leaks = 1.0/hours * lat;
EventDataType leak = day->avg(CPAP_Leak); EventDataType leak = day->avg(CPAP_Leak);
EventDataType leakdays = p_profile->calcAvg(CPAP_Leak, MT_CPAP, starttime, date); EventDataType leakdays = p_profile->calcAvg(CPAP_Leak, MT_CPAP, starttime, endtime);
if ((leak < leakdays) && ((leakdays - leak) >= 0.1)) { if ((leak < leakdays) && ((leakdays - leak) >= 0.1)) {
comp = under; comp = under;