24 |
protected SavedStatBean convertRow(ResultSet res) throws SQLException { |
protected SavedStatBean convertRow(ResultSet res) throws SQLException { |
25 |
SavedStatBean bean = new SavedStatBean(); |
SavedStatBean bean = new SavedStatBean(); |
26 |
|
|
27 |
bean.statisticsdate = res.getString(1); |
bean.label = res.getString(1); |
28 |
bean.station = res.getString(2); |
bean.station = res.getString(2); |
29 |
bean.location = res.getString(3); |
bean.location = res.getString(3); |
30 |
bean.name = res.getString(4); |
bean.name = res.getString(4); |
53 |
String sqlAvg = "SELECT count(*) AS count, round(avg(location+name+favorites),1) AS station, round(avg(location),1) as location, round(avg(name),1) as name, round(avg(favorites),1) as favorites, " + |
String sqlAvg = "SELECT count(*) AS count, round(avg(location+name+favorites),1) AS station, round(avg(location),1) as location, round(avg(name),1) as name, round(avg(favorites),1) as favorites, " + |
54 |
"round(avg(departure),1) as departure, round(avg(depcache),1) as depcache, round(avg(deperror),1) as deperror, " + |
"round(avg(departure),1) as departure, round(avg(depcache),1) as depcache, round(avg(deperror),1) as deperror, " + |
55 |
"round(avg(timetable),1) as timetable, round(avg(timecache),1) as timecache, round(avg(timeerror),1) as timeerror " + |
"round(avg(timetable),1) as timetable, round(avg(timecache),1) as timecache, round(avg(timeerror),1) as timeerror " + |
56 |
"FROM trainstatistics"; |
"FROM trainstatistics " + |
57 |
|
"WHERE statisticsdate <> now()::date "; |
58 |
|
|
59 |
ResultSet resAvg = stmt.executeQuery(sqlAvg); |
ResultSet resAvg = stmt.executeQuery(sqlAvg); |
60 |
resAvg.next(); |
resAvg.next(); |
61 |
SavedStatBean avgBean = convertRow(resAvg); |
SavedStatBean avgBean = convertRow(resAvg); |
|
stats.add(avgBean); |
|
62 |
|
|
63 |
//////////////////////////////////////////////// |
//////////////////////////////////////////////// |
64 |
|
|
76 |
stats.add(bean); |
stats.add(bean); |
77 |
|
|
78 |
} |
} |
79 |
|
|
80 |
|
conn.close(); |
81 |
|
|
82 |
|
|
83 |
|
request.setAttribute("avg", avgBean); |
|
// request.setAttribute("avg", avgBean); |
|
84 |
request.setAttribute("stats", stats); |
request.setAttribute("stats", stats); |
85 |
request.getRequestDispatcher("/savedstatistics.jsp").forward(request, response); |
request.getRequestDispatcher("/savedstatistics.jsp").forward(request, response); |
86 |
|
|