X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=server%2Fcompbio%2Fcontrollers%2FDailyStatisticsController.java;h=edfe87690c9ca4d829617f7cac5457600b52c902;hb=4c4641df797893a1c4dfd39367086cbf5ec34645;hp=fd7a0db0529dcf49f391bd68b9543f03c446afe7;hpb=ca0ed055669c0c5d81689e52da5325578a221888;p=proteocache.git diff --git a/server/compbio/controllers/DailyStatisticsController.java b/server/compbio/controllers/DailyStatisticsController.java index fd7a0db..edfe876 100644 --- a/server/compbio/controllers/DailyStatisticsController.java +++ b/server/compbio/controllers/DailyStatisticsController.java @@ -26,6 +26,14 @@ public class DailyStatisticsController { @RequestMapping(value = "/stat", method = RequestMethod.GET) public String initFindForm(Map model) { + Calendar cal = Calendar.getInstance(); + String date2 = cal.get(Calendar.YEAR) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.DATE); + cal.add(Calendar.DATE, -3); + String date1 = cal.get(Calendar.YEAR) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.DATE); + + model.put("date1", date1); + model.put("date2", date2); + return "queryJobStatistics"; } @@ -40,13 +48,13 @@ public class DailyStatisticsController { date1 = StatisticsProt.DateFormatYYMMDD(cr.earliestDate()); date2 = cal.get(Calendar.YEAR) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.DAY_OF_MONTH); } - model.put("data1", date1); - model.put("data2", date2); + model.put("date1", date1); + model.put("date2", date2); List res = cr.countJobs(date1, date2); model.put("result", res); final long endTime = System.currentTimeMillis(); model.put("timeExecution", (endTime - startTime)); - model.put("flag", option); + model.put("option", option); return "/reportJobStatistics"; } @@ -54,19 +62,28 @@ public class DailyStatisticsController { public String findJobsInOneDay(@RequestParam("date") String date, Map model) throws ParseException { final long startTime = System.currentTimeMillis(); + String realdate; final SimpleDateFormat formaterDDMMYY = new SimpleDateFormat("dd/MM/yyyy"); final SimpleDateFormat formaterYYMMDD = new SimpleDateFormat("yyyy/MM/dd"); - String date1 = formaterYYMMDD.format(new Date(formaterDDMMYY.parse(date).getTime())); - + try { + long thetime = formaterYYMMDD.parse(date).getTime(); + if (thetime < 0) { + realdate = date; + } else { + realdate = formaterDDMMYY.format(new Date(thetime)); + } + } catch (ParseException e) { + realdate = date; + } + CassandraRequester cr = new CassandraRequester(); - //List r1 = cr.countJobs(date1, date1); - List r = cr.readJobByDay(date); + // IMPORTANT: input should be suppied in the format: DD/MM/YYYY + List r = cr.readJobByDay(realdate); model.put("results", r); model.put("njobs", r.size()); - model.put("date", date1); + model.put("date", realdate); final long endTime = System.currentTimeMillis(); model.put("timeExecution", (endTime - startTime)); - System.out.println("Request for date = " + date1 + ": " + r.size() + " jobs found"); return "/reportJobStatisticsOneDay"; } }