15 |
import javax.servlet.http.HttpServletRequest; |
import javax.servlet.http.HttpServletRequest; |
16 |
import javax.servlet.http.HttpServletResponse; |
import javax.servlet.http.HttpServletResponse; |
17 |
|
|
18 |
|
import dk.thoerup.traininfoservice.db.DBConnection; |
19 |
|
|
20 |
|
|
21 |
@WebServlet(urlPatterns={"/SavedStatistics"}) |
@WebServlet(urlPatterns={"/SavedStatistics"}) |
22 |
public class SavedStatistics extends HttpServlet { |
public class SavedStatistics extends HttpServlet { |
26 |
protected SavedStatBean convertRow(ResultSet res) throws SQLException { |
protected SavedStatBean convertRow(ResultSet res) throws SQLException { |
27 |
SavedStatBean bean = new SavedStatBean(); |
SavedStatBean bean = new SavedStatBean(); |
28 |
|
|
29 |
bean.statisticsdate = res.getString(1); |
bean.label = res.getString(1); |
30 |
bean.station = res.getString(2); |
bean.station = res.getString(2); |
31 |
bean.location = res.getString(3); |
bean.location = res.getString(3); |
32 |
bean.name = res.getString(4); |
bean.name = res.getString(4); |
55 |
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, " + |
56 |
"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, " + |
57 |
"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 " + |
58 |
"FROM trainstatistics"; |
"FROM trainstatistics " + |
59 |
|
"WHERE statisticsdate <> now()::date "; |
60 |
|
|
61 |
ResultSet resAvg = stmt.executeQuery(sqlAvg); |
ResultSet resAvg = stmt.executeQuery(sqlAvg); |
62 |
resAvg.next(); |
resAvg.next(); |
78 |
stats.add(bean); |
stats.add(bean); |
79 |
|
|
80 |
} |
} |
81 |
|
|
82 |
|
conn.close(); |
83 |
|
|
84 |
|
|
85 |
request.setAttribute("avg", avgBean); |
request.setAttribute("avg", avgBean); |