c0bbd2bb0ff591e4e7f1fd8c2212d43d069536c4
3 #include "statsweekdayave.h"
5 StatsWeekdayAve::StatsWeekdayAve(JourneyModel
* journeys
) :
8 title
= "Average journey time (mins)";
10 labels
= QStringList
{"M", "T", "W", "Th", "F", "S", "Su"};
13 void StatsWeekdayAve::update() {
15 unsigned int count
[7];
18 qDebug() << "Calculating values";
21 for (pos
= 0; pos
< 7; pos
++) {
26 foreach (Journey
const &journey
, journeys
->getData()) {
27 QDate date
= journey
.getStartDate();
28 int dayofweek
= date
.dayOfWeek() - 1;
30 duration
[dayofweek
] += journey
.getDuration();
36 for (pos
= 0; pos
< 7; pos
++) {
39 result
= ((duration
[pos
] / 60.0) / (double)count
[pos
]);
41 if (result
> maxval
) {
47 step
= maxval
> 5.0 ? qRound(maxval
/ 5.0) : (maxval
/ 5.0);
49 qDebug() << "Calculated values";