<commit_before><?php
namespace RecipeBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

use RecipeBundle\Entity\Recipe;

class UpdateRatingsCommand extends ContainerAwareCommand
{
    protected function configure()
    {
        $this
            ->setName('recipe:update:ratings')
            ->setDescription('Updates the ratings of allrecipe')
        ;
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $em = $this->getContainer()->get('doctrine')->getManager();

        $recipes = $em->getRepository('RecipeBundle:Recipe')->findByIsFinished(1);

        $text = "";

        foreach ( $recipes as $recipe){
            $score = 0;
            $reviews = $recipe->getReviews();
            if (count($reviews) == 0)
                $rating = 0;
            else {
                foreach ($recipe->getReviews() as $rating){
                    $score += $rating->getRating();
                }
                $rating = $score / count($reviews);
            }
            if ($rating >= 2 )
                $recipe->setIsPublished(true);
            else
                $recipe->setIsPublished(false);

            $recipe->setRating($rating);
            $output->writeln($recipe->getTitle() . ' : ' . $rating . '   ');
            $em->persist($recipe);
        }
        $em->flush();

    }
}<commit_msg>change the condition to be published<commit_after><?php
namespace RecipeBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

use RecipeBundle\Entity\Recipe;

class UpdateRatingsCommand extends ContainerAwareCommand
{
    protected function configure()
    {
        $this
            ->setName('recipe:update:ratings')
            ->setDescription('Updates the ratings of allrecipe')
        ;
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $em = $this->getContainer()->get('doctrine')->getManager();

        $recipes = $em->getRepository('RecipeBundle:Recipe')->findByIsFinished(1);

        $text = "";

        foreach ( $recipes as $recipe){
            $score = 0;
            $reviews = $recipe->getReviews();
            if (count($reviews) == 0)
                $rating = 0;
            else {
                foreach ($recipe->getReviews() as $rating){
                    $score += $rating->getRating();
                }
                $rating = $score / count($reviews);
            }
            if ($rating >= 2 && count($reviews) > 4)
                $recipe->setIsPublished(true);
            else
                $recipe->setIsPublished(false);

            $recipe->setRating($rating);
            $output->writeln($recipe->getTitle() . ' : ' . $rating . '   ');
            $em->persist($recipe);
        }
        $em->flush();

    }
}
{'fraction_non_alphanumeric': 0.13411258074438634, 'fraction_numerical': 0.003383574284835435, 'mean_word_length': 2.166504381694255, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 40, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2493047', 'n_tokens_mistral': 929, 'n_tokens_neox': 882, 'n_words': 155}