mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-06 19:20:45 +00:00
Statistic:Date Range Mode enhanced to be similar to standard mode
This commit is contained in:
parent
925a621f20
commit
1a1385e74b
@ -1002,15 +1002,18 @@ struct Period {
|
|||||||
next = last.addMonths(advance).addDays(+1);
|
next = last.addMonths(advance).addDays(+1);
|
||||||
} else {
|
} else {
|
||||||
next = last.addDays(advance);
|
next = last.addDays(advance);
|
||||||
}
|
};
|
||||||
if (next<=first) {
|
if (next<=first) {
|
||||||
|
if ( (next<first) && (p_profile->general->statReportMode() == STAT_MODE_RANGE) ){
|
||||||
|
name = QObject::tr("Everything");
|
||||||
|
}
|
||||||
finished = true;
|
finished = true;
|
||||||
next = first;
|
next = first;
|
||||||
}
|
}
|
||||||
name = name + "<br>" + next.toString(Qt::SystemLocaleShortDate) ;
|
name = name + "<br>" + next.toString(Qt::SystemLocaleShortDate) ;
|
||||||
if (advance!=0) {
|
if (advance!=0) {
|
||||||
name = name + " - " + last.toString(Qt::SystemLocaleShortDate);
|
name = name + " - " + last.toString(Qt::SystemLocaleShortDate);
|
||||||
}
|
};
|
||||||
this->header = name;
|
this->header = name;
|
||||||
this->start = next ;
|
this->start = next ;
|
||||||
this->end = last ;
|
this->end = last ;
|
||||||
@ -1298,16 +1301,7 @@ QString Statistics::GenerateCPAPUsage()
|
|||||||
|
|
||||||
// Clear the periods (columns)
|
// Clear the periods (columns)
|
||||||
periods.clear();
|
periods.clear();
|
||||||
if (p_profile->general->statReportMode() == STAT_MODE_STANDARD) {
|
if (p_profile->general->statReportMode() == STAT_MODE_MONTHLY) {
|
||||||
// note add days or addmonths returns the start of the next day or the next month.
|
|
||||||
// must shorten one day for each. Month executed in Period method
|
|
||||||
bool finished = false; // used to detect end of data - when less than a year of data.
|
|
||||||
periods.push_back(Period(first,last,finished, 0, false ,tr("Most Recent")));
|
|
||||||
periods.push_back(Period(first,last,finished, -6, false ,tr("Last Week")));
|
|
||||||
periods.push_back(Period(first,last,finished, -29,false, tr("Last 30 Days")));
|
|
||||||
periods.push_back(Period(first,last,finished, -6,true, tr("Last 6 Months")));
|
|
||||||
periods.push_back(Period(first,last,finished, -12,true,tr("Last Year")));
|
|
||||||
} else if (p_profile->general->statReportMode() == STAT_MODE_MONTHLY) {
|
|
||||||
QDate l=last,s=last;
|
QDate l=last,s=last;
|
||||||
|
|
||||||
periods.push_back(Period(last,last,tr("Last Session")));
|
periods.push_back(Period(last,last,tr("Last Session")));
|
||||||
@ -1330,13 +1324,24 @@ QString Statistics::GenerateCPAPUsage()
|
|||||||
for (; j < number_periods; ++j) {
|
for (; j < number_periods; ++j) {
|
||||||
periods.push_back(Period(last,last, ""));
|
periods.push_back(Period(last,last, ""));
|
||||||
}
|
}
|
||||||
} else { // STAT_MODE_RANGE
|
} else { // STAT_MODE_STANDARD or STAT_MODE_RANGE
|
||||||
|
if (p_profile->general->statReportMode() == STAT_MODE_RANGE) {
|
||||||
first = p_profile->general->statReportRangeStart();
|
first = p_profile->general->statReportRangeStart();
|
||||||
last = p_profile->general->statReportRangeEnd();
|
last = p_profile->general->statReportRangeEnd();
|
||||||
if (first > last) {
|
if (first > last) { first=last; };
|
||||||
first = last;
|
}
|
||||||
|
// note add days or addmonths returns the start of the next day or the next month.
|
||||||
|
// must shorten one day for each. Month executed in Period method
|
||||||
|
bool finished = false; // used to detect end of data - when less than a year of data.
|
||||||
|
periods.push_back(Period(first,last,finished, 0, false ,tr("Most Recent")));
|
||||||
|
periods.push_back(Period(first,last,finished, -6, false ,tr("Last Week")));
|
||||||
|
periods.push_back(Period(first,last,finished, -29,false, tr("Last 30 Days")));
|
||||||
|
periods.push_back(Period(first,last,finished, -6,true, tr("Last 6 Months")));
|
||||||
|
if (p_profile->general->statReportMode() == STAT_MODE_STANDARD) {
|
||||||
|
periods.push_back(Period(first,last,finished, -12,true,tr("Last Year")));
|
||||||
|
} else {
|
||||||
|
periods.push_back(Period(first,last,finished, last.daysTo(first),false,tr("Everything")));
|
||||||
}
|
}
|
||||||
periods.push_back(Period(first,last,first.toString(MedDateFormat)+" - "+last.toString(MedDateFormat)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int days = p_profile->countDays(row.type, first, last);
|
int days = p_profile->countDays(row.type, first, last);
|
||||||
@ -1375,9 +1380,7 @@ QString Statistics::GenerateCPAPUsage()
|
|||||||
} else if (row.calc == SC_DAYS) {
|
} else if (row.calc == SC_DAYS) {
|
||||||
QDate first=p_profile->FirstGoodDay(row.type);
|
QDate first=p_profile->FirstGoodDay(row.type);
|
||||||
QDate last=p_profile->LastGoodDay(row.type);
|
QDate last=p_profile->LastGoodDay(row.type);
|
||||||
if (last > p_profile->general->statReportDate() ) {
|
// there no relationship to reports date. It just specifies the number of days used for a cetain range of dates.
|
||||||
last = p_profile->general->statReportDate();
|
|
||||||
}
|
|
||||||
QString & machine = machinenames[row.type];
|
QString & machine = machinenames[row.type];
|
||||||
int value=p_profile->countDays(row.type, first, last);
|
int value=p_profile->countDays(row.type, first, last);
|
||||||
|
|
||||||
@ -1853,7 +1856,11 @@ QString StatisticsRow::value(QDate start, QDate end)
|
|||||||
if (calc == SC_AHI) {
|
if (calc == SC_AHI) {
|
||||||
value = QString("%1").arg(calcAHI(start, end), 0, 'f', decimals);
|
value = QString("%1").arg(calcAHI(start, end), 0, 'f', decimals);
|
||||||
} else if (calc == SC_HOURS) {
|
} else if (calc == SC_HOURS) {
|
||||||
|
if (days==0) {
|
||||||
|
value = QString("0");
|
||||||
|
} else {
|
||||||
value = QString("%1").arg(formatTime(p_profile->calcHours(type, start, end) / days));
|
value = QString("%1").arg(formatTime(p_profile->calcHours(type, start, end) / days));
|
||||||
|
}
|
||||||
} else if (calc == SC_COMPLIANCE) {
|
} else if (calc == SC_COMPLIANCE) {
|
||||||
float c = p_profile->countCompliantDays(type, start, end );
|
float c = p_profile->countCompliantDays(type, start, end );
|
||||||
// float p = (100.0 / days) * c;
|
// float p = (100.0 / days) * c;
|
||||||
|
Loading…
Reference in New Issue
Block a user