mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-22 05:30:44 +00:00
Correct percentile calculation for multiple days
- Previously, would stop and return 0 if any day in range was suumary only - Now, just ignores summary-only days if there are days with data - Re-indentation makes change look bigger than it is
This commit is contained in:
parent
555639e78b
commit
6406545c33
@ -1724,69 +1724,70 @@ EventDataType Profile::calcPercentile(ChannelID code, EventDataType percent, Mac
|
|||||||
|
|
||||||
qint64 SN = 0;
|
qint64 SN = 0;
|
||||||
bool timeweight;
|
bool timeweight;
|
||||||
bool summaryOnly = false;
|
bool summaryOnly = true;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
Day *day = GetGoodDay(date, mt);
|
Day *day = GetGoodDay(date, mt);
|
||||||
|
|
||||||
if (day) {
|
if (day) {
|
||||||
if (day->summaryOnly()) {
|
if (day->summaryOnly()) {
|
||||||
summaryOnly = true;
|
date = date.addDays(1);
|
||||||
break;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
summaryOnly = false;
|
||||||
|
|
||||||
// why was this nested like this???
|
// why was this nested like this???
|
||||||
//for (int i = 0; i < day->size(); i++) {
|
//for (int i = 0; i < day->size(); i++) {
|
||||||
for (auto & sess : day->sessions) {
|
for (auto & sess : day->sessions) {
|
||||||
if (!sess->enabled()) {
|
if (!sess->enabled()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
gain = sess->m_gain[code];
|
gain = sess->m_gain[code];
|
||||||
|
|
||||||
if (!gain) { gain = 1; }
|
if (!gain) { gain = 1; }
|
||||||
|
|
||||||
vsi = sess->m_valuesummary.find(code);
|
vsi = sess->m_valuesummary.find(code);
|
||||||
|
|
||||||
if (vsi == sess->m_valuesummary.end()) { continue; }
|
if (vsi == sess->m_valuesummary.end()) { continue; }
|
||||||
|
|
||||||
tsi = sess->m_timesummary.find(code);
|
tsi = sess->m_timesummary.find(code);
|
||||||
timeweight = (tsi != sess->m_timesummary.end());
|
timeweight = (tsi != sess->m_timesummary.end());
|
||||||
|
|
||||||
QHash<EventStoreType, EventStoreType> &vsum = vsi.value();
|
QHash<EventStoreType, EventStoreType> &vsum = vsi.value();
|
||||||
QHash<EventStoreType, quint32> &tsum = tsi.value();
|
QHash<EventStoreType, quint32> &tsum = tsi.value();
|
||||||
|
|
||||||
if (timeweight) {
|
if (timeweight) {
|
||||||
for (auto k=tsum.begin(), tsumend=tsum.end(); k != tsumend; k++) {
|
for (auto k=tsum.begin(), tsumend=tsum.end(); k != tsumend; k++) {
|
||||||
weight = k.value();
|
weight = k.value();
|
||||||
value = EventDataType(k.key()) * gain;
|
value = EventDataType(k.key()) * gain;
|
||||||
|
|
||||||
SN += weight;
|
SN += weight;
|
||||||
wmi = wmap.find(value);
|
wmi = wmap.find(value);
|
||||||
|
|
||||||
if (wmi == wmap.end()) {
|
if (wmi == wmap.end()) {
|
||||||
wmap[value] = weight;
|
wmap[value] = weight;
|
||||||
} else {
|
} else {
|
||||||
wmi.value() += weight;
|
wmi.value() += weight;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
for (auto k=vsum.begin(), vsumend=vsum.end(); k!=vsumend; k++) {
|
} else {
|
||||||
weight = k.value();
|
for (auto k=vsum.begin(), vsumend=vsum.end(); k!=vsumend; k++) {
|
||||||
value = EventDataType(k.key()) * gain;
|
weight = k.value();
|
||||||
|
value = EventDataType(k.key()) * gain;
|
||||||
|
|
||||||
SN += weight;
|
SN += weight;
|
||||||
wmi = wmap.find(value);
|
wmi = wmap.find(value);
|
||||||
|
|
||||||
if (wmi == wmap.end()) {
|
if (wmi == wmap.end()) {
|
||||||
wmap[value] = weight;
|
wmap[value] = weight;
|
||||||
} else {
|
} else {
|
||||||
wmi.value() += weight;
|
wmi.value() += weight;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// }
|
}
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
date = date.addDays(1);
|
date = date.addDays(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user