예제 #1
0
 protected Set<Integer> calculateAverageServiceDurations(
     Map<Integer, Set<TicketUpdate>> ticketNumberToUpdates, QueueInfo queueInfo) {
   Set<Integer> averageServiceDurations = new HashSet<Integer>();
   Set<Integer> averageTicketServiceDurationsPerTicket = new HashSet<Integer>();
   Set<Integer> ticketNumbers = ticketNumberToUpdates.keySet();
   Set<TicketUpdate> updatesPerTicket;
   Date queueOpeningTime = getQueueOpeningTimeByQueueId(queueInfo.getQueueId());
   for (int ticketNumber : ticketNumbers) {
     averageTicketServiceDurationsPerTicket.clear();
     updatesPerTicket = ticketNumberToUpdates.get(ticketNumber);
     for (TicketUpdate ticketUpdate : updatesPerTicket) {
       long offsetFromQueueOpeningToUpdateTime =
           ticketUpdate.getCreated().getTime() - queueOpeningTime.getTime();
       int averageTicketServiceDurationForUpdate =
           (int) offsetFromQueueOpeningToUpdateTime / ticketNumber;
       averageTicketServiceDurationsPerTicket.add(averageTicketServiceDurationForUpdate);
     }
     int totalAverageServiceDuration = 0;
     for (int averageServiceDuration : averageTicketServiceDurationsPerTicket) {
       totalAverageServiceDuration += averageServiceDuration;
     }
     int averageServiceDuration =
         totalAverageServiceDuration / averageTicketServiceDurationsPerTicket.size();
     averageServiceDurations.add(averageServiceDuration);
   }
   return averageServiceDurations;
 }
예제 #2
0
 private void updateTodaysQueueAverageServiceDuration(
     int ticketAverageServiceDuration, QueueInfo queueInfo) {
   QueueStats queueStats = queueService.getQueueStatsByQueueId(queueInfo.getQueueId());
   Date todayAtMidnight = TimeGenerator.getTodayMidnightDate();
   queueStats.setDate(todayAtMidnight);
   queueStats.setCalculatedAverageWaitingDuration(ticketAverageServiceDuration);
   queueService.updateQueueStats(queueStats);
 }
예제 #3
0
 public TicketUpdate getHighestTicketUpdatesFromToday(QueueInfo queueInfo) {
   int queueId = queueInfo.getQueueId();
   Date queueOpeningTime = getQueueOpeningTimeByQueueId(queueId);
   Date queueClosingTime = getQueueClosingTimeByQueueId(queueId);
   TicketUpdate highestTicketUpdates =
       ticketDao.readHighestTicketUpdateByQueueAndDay(
           queueInfo, queueOpeningTime, queueClosingTime, MINIMUM_ACCEPTED_INPUT_QUALITY);
   return highestTicketUpdates;
 }
예제 #4
0
 private Collection<TicketUpdate> getTicketUpdatesFromToday(QueueInfo queueInfo) {
   int queueId = queueInfo.getQueueId();
   Date queueOpeningTime = getQueueOpeningTimeByQueueId(queueId);
   Date queueClosingTime = getQueueClosingTimeByQueueId(queueId);
   Collection<TicketUpdate> todayTicketUpdates =
       ticketDao.readTicketUpdatesByQueueAndDate(
           queueInfo, queueOpeningTime, queueClosingTime, MINIMUM_ACCEPTED_INPUT_QUALITY);
   return todayTicketUpdates;
 }