original_string: public function getByLocale(LocaleEntity $locale)
      {
          $app = Application::getFacadeApplication();
          $result = $this->find($locale);
          if ($result === null) {
              $em = $this->getEntityManager();
              try {
                  $numTranslatable = (int) $app->make(TranslatableRepository::class)
                      ->createQueryBuilder('t')
                          ->select('count(t.id)')
                          ->getQuery()->getSingleScalarResult();
              } catch (NoResultException $x) {
                  $numTranslatable = 0;
              }
              if ($numTranslatable === 0) {
                  $numApprovedTranslations = 0;
              } else {
                  try {
                      $numApprovedTranslations = (int) $app->make(TranslationRepository::class)
                      ->createQueryBuilder('t')
                          ->select('count(t.id)')
                          ->where('t.locale = :locale')->setParameter('locale', $locale)
                          ->andWhere('t.current = 1')
                          ->getQuery()->getSingleScalarResult();
                  } catch (NoResultException $x) {
                      $numApprovedTranslations = 0;
                  }
              }
              $result = LocaleStatsEntity::create($locale, $numTranslatable, $numApprovedTranslations);
              $em->persist($result);
              $em->flush($result);
          }
  
          return $result;
      }
code: public function getByLocale(LocaleEntity $locale)
      {
          $app = Application::getFacadeApplication();
          $result = $this->find($locale);
          if ($result === null) {
              $em = $this->getEntityManager();
              try {
                  $numTranslatable = (int) $app->make(TranslatableRepository::class)
                      ->createQueryBuilder('t')
                          ->select('count(t.id)')
                          ->getQuery()->getSingleScalarResult();
              } catch (NoResultException $x) {
                  $numTranslatable = 0;
              }
              if ($numTranslatable === 0) {
                  $numApprovedTranslations = 0;
              } else {
                  try {
                      $numApprovedTranslations = (int) $app->make(TranslationRepository::class)
                      ->createQueryBuilder('t')
                          ->select('count(t.id)')
                          ->where('t.locale = :locale')->setParameter('locale', $locale)
                          ->andWhere('t.current = 1')
                          ->getQuery()->getSingleScalarResult();
                  } catch (NoResultException $x) {
                      $numApprovedTranslations = 0;
                  }
              }
              $result = LocaleStatsEntity::create($locale, $numTranslatable, $numApprovedTranslations);
              $em->persist($result);
              $em->flush($result);
          }
  
          return $result;
      }
code_tokens: public function getByLocale ( LocaleEntity $ locale ) { $ app = Application :: getFacadeApplication ( ) ; $ result = $ this -> find ( $ locale ) ; if ( $ result === null ) { $ em = $ this -> getEntityManager ( ) ; try { $ numTranslatable = ( int ) $ app -> make ( TranslatableRepository :: class ) -> createQueryBuilder ( 't' ) -> select ( 'count(t.id)' ) -> getQuery ( ) -> getSingleScalarResult ( ) ; } catch ( NoResultException $ x ) { $ numTranslatable = 0 ; } if ( $ numTranslatable === 0 ) { $ numApprovedTranslations = 0 ; } else { try { $ numApprovedTranslations = ( int ) $ app -> make ( TranslationRepository :: class ) -> createQueryBuilder ( 't' ) -> select ( 'count(t.id)' ) -> where ( 't.locale = :locale' ) -> setParameter ( 'locale' , $ locale ) -> andWhere ( 't.current = 1' ) -> getQuery ( ) -> getSingleScalarResult ( ) ; } catch ( NoResultException $ x ) { $ numApprovedTranslations = 0 ; } } $ result = LocaleStatsEntity :: create ( $ locale , $ numTranslatable , $ numApprovedTranslations ) ; $ em -> persist ( $ result ) ; $ em -> flush ( $ result ) ; } return $ result ; }
docstring: Get the stats for a specific locale.
  If the stats does not exist yet, they are created.
  
  @return LocaleStatsEntity
docstring_tokens: Get the stats for a specific locale . If the stats does not exist yet they are created .