/**
  * @param Project $project
  */
 private function updateProjectSprints(Project $project)
 {
     $this->output->write(sprintf('%-30s', '  - Updating Sprints'));
     $previewSprints = $this->previewService->getSprints($project->getId());
     $created = 0;
     $updated = 0;
     foreach ($previewSprints as $previewSprint) {
         $sprint = $this->entityManager->getRepository('ProjectPreviewPreviewBundle:Sprint')->find($previewSprint->id);
         if (is_null($sprint)) {
             $sprint = new Sprint();
             $sprint->setId($previewSprint->id);
             $created++;
         } else {
             $updated++;
         }
         $sprint->setProject($project);
         $sprint->setName($previewSprint->name);
         $sprint->setCompleted($previewSprint->completed);
         $this->entityManager->persist($sprint);
     }
     $this->entityManager->flush();
     $this->output->writeln(sprintf('done (total: % 4d, created: % 4d, updated: % 4d)', $created + $updated, $created, $updated));
 }
 /**
  * @param Sprint    $sprint
  * @param \DateTime $date
  *
  * @return int
  */
 public function getEstimatedTimeForDoneTicketByDate(Sprint $sprint, \DateTime $date)
 {
     $estimated = 0;
     foreach ($sprint->getTickets() as $ticket) {
         if ($ticket->getSprint() != $sprint || $ticket->getType() != 'task') {
             continue;
         }
         $status = $this->ticketService->getStateByDate($ticket, $date);
         if (!in_array($status, ['En Revue', 'Fermé'])) {
             continue;
         }
         $estimated += $ticket->getEstimatedTime();
     }
     return $estimated;
 }
 /**
  * @param User   $user
  * @param Sprint $sprint
  *
  * @return bool
  */
 protected function checkClientRead(User $user, Sprint $sprint)
 {
     return in_array($user, $sprint->getProject()->getClients()->toArray());
 }