Ejemplo n.º 1
0
 public MircString stats(String duration) {
   // valid durations
   // all, year, month, week, day
   MircString mircString = new MircString();
   // default
   LocalDate dateFrom = LocalDate.now().minusYears(10);
   if (duration.equals("year")) {
     dateFrom = LocalDate.now().minusYears(1);
   } else if (duration.equals("month")) {
     dateFrom = LocalDate.now().minusMonths(1);
   } else if (duration.equals("week")) {
     dateFrom = LocalDate.now().minusWeeks(1);
   } else if (duration.equals("day")) {
     dateFrom = LocalDate.now().minusDays(1);
   }
   LocalDate dateTo = LocalDate.now();
   ArrayList<NicksAndLines> unsortedOutput = Statistics.topNicks(quotes, dateFrom, dateTo);
   ArrayList<NicksAndLines> output = NicksAndLines.sortDesc(unsortedOutput);
   StringBuffer stringBuffer = new StringBuffer();
   String initial = "Quote summary: ";
   stringBuffer.append(initial);
   for (int i = 0; i < output.size() && i < 10; i++) {
     if (i > 0) {
       stringBuffer.append(", ");
     }
     String tempString = output.get(i).getNick() + " - " + output.get(i).getLines();
     stringBuffer.append(tempString);
   }
   mircString = MircString.of(stringBuffer.toString());
   return mircString;
 }
Ejemplo n.º 2
0
 public MircString quotesToday() {
   quotes = ReadLog.load(file);
   LocalDate date = LocalDate.now();
   Long output = Statistics.dailyQuotes(quotes, date);
   System.out.println("quotecache output: " + output);
   String inputString = "Total quotes for today: " + output.toString();
   MircString string = MircString.of(inputString);
   return string;
 }
Ejemplo n.º 3
0
 public MircString randomSingleQuote() {
   String string = Statistics.randomSingleQuote(quotes);
   String outputString = "A random quote: " + string;
   MircString mircString = MircString.of(outputString);
   return mircString;
 }