X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=server%2Fcompbio%2Fcontrollers%2FDailyStatisticsController.java;h=b6d5bde7775c60def545ac1719e1a34baad39efa;hb=6e4bd47e22036a7f0c7b66fe7ee4f188a7cffddb;hp=22df505ae0b9896fb7e90b2438eaa743de6e72f3;hpb=4a5237c1930f267a2e9f7a9d735f1a556c9f018b;p=proteocache.git diff --git a/server/compbio/controllers/DailyStatisticsController.java b/server/compbio/controllers/DailyStatisticsController.java index 22df505..b6d5bde 100644 --- a/server/compbio/controllers/DailyStatisticsController.java +++ b/server/compbio/controllers/DailyStatisticsController.java @@ -12,10 +12,9 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; - -import compbio.cassandra.DataBase; +import compbio.cassandra.DateBean; +import compbio.cassandra.TotalJobsStatisticBean; import compbio.statistic.CassandraRequester; -import compbio.statistic.StatisticsProt; /** * @author Alexander Sherstnev @@ -33,7 +32,7 @@ public class DailyStatisticsController { model.put("date1", date1); model.put("date2", date2); - + return "queryJobStatistics"; } @@ -45,36 +44,47 @@ public class DailyStatisticsController { CassandraRequester cr = new CassandraRequester(); if (option.equals("AllDates,off")) { Calendar cal = Calendar.getInstance(); - date1 = StatisticsProt.DateFormatYYMMDD(cr.earliestDate()); + date1 = cr.earliestDateString(); date2 = cal.get(Calendar.YEAR) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.DAY_OF_MONTH); } model.put("date1", date1); model.put("date2", date2); - List res = cr.countJobs(date1, date2); + TotalJobsStatisticBean res = cr.countJobs(date1, date2); model.put("result", res); + model.put("ndays", res.getDateTotal().size()); final long endTime = System.currentTimeMillis(); model.put("timeExecution", (endTime - startTime)); model.put("option", option); return "/reportJobStatistics"; } - + @RequestMapping(value = "/stat/oneday", method = RequestMethod.GET) 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 + DateBean r = cr.readJobByDay(realdate); model.put("results", r); - model.put("njobs", r.size()); - model.put("date", date1); + if (r != null) + model.put("njobs", r.getJobidAndSeq().size()); + 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"; } }