<commit_before><?php
/*
 * WellCommerce Open-Source E-Commerce Platform
 *
 * This file is part of the WellCommerce package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information,
 * please view the LICENSE file that was distributed with this source code.
 */

namespace WellCommerce\Bundle\CategoryBundle\Repository;

use Symfony\Component\HttpFoundation\ParameterBag;
use WellCommerce\Bundle\CategoryBundle\Entity\Category;
use WellCommerce\Bundle\CoreBundle\Repository\AbstractEntityRepository;

/**
 * Class CategoryRepository
 *
 * @package WellCommerce\Bundle\CategoryBundle\Repository
 * @author  <NAME> <<EMAIL>>
 */
class CategoryRepository extends AbstractEntityRepository implements CategoryRepositoryInterface
{
    /**
     * {@inheritdoc}
     */
    public function getTreeItems()
    {
        $queryBuilder = $this->getQueryBuilder('category');
        $queryBuilder->select('
            category.id,
            category.hierarchy,
            IDENTITY(category.parent) parent,
            COUNT(category_children.id) children,
            category_translation.name
        ');
        $queryBuilder->leftJoin(
            'WellCommerceCategoryBundle:Category',
            'category_children',
            'WITH',
            'category.parent = category_children.id');
        $queryBuilder->leftJoin(
            'WellCommerceCategoryBundle:CategoryTranslation',
            'category_translation',
            'WITH',
            'category.id = category_translation.translatable AND category_translation.locale = :locale');
        $queryBuilder->groupBy('category.id');
        $queryBuilder->setParameter('locale', $this->getCurrentLocale());
        $query = $queryBuilder->getQuery();
        $items = $query->getArrayResult();

        $categoriesTree = [];
        foreach ($items as $item) {
            $categoriesTree[$item['id']] = [
                'id'          => $item['id'],
                'name'        => $item['name'],
                'hasChildren' => (bool)$item['children'],<commit_msg>Fixed children count in categories<commit_after><?php
/*
 * WellCommerce Open-Source E-Commerce Platform
 *
 * This file is part of the WellCommerce package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information,
 * please view the LICENSE file that was distributed with this source code.
 */

namespace WellCommerce\Bundle\CategoryBundle\Repository;

use Symfony\Component\HttpFoundation\ParameterBag;
use WellCommerce\Bundle\CategoryBundle\Entity\Category;
use WellCommerce\Bundle\CoreBundle\Repository\AbstractEntityRepository;

/**
 * Class CategoryRepository
 *
 * @package WellCommerce\Bundle\CategoryBundle\Repository
 * @author  <NAME> <<EMAIL>>
 */
class CategoryRepository extends AbstractEntityRepository implements CategoryRepositoryInterface
{
    /**
     * {@inheritdoc}
     */
    public function getTreeItems()
    {
        $queryBuilder = $this->getQueryBuilder('category');
        $queryBuilder->select('
            category.id,
            category.hierarchy,
            IDENTITY(category.parent) parent,
            COUNT(category_children.id) children,
            category_translation.name
        ');
        $queryBuilder->leftJoin(
            'WellCommerceCategoryBundle:Category',
            'category_children',
            'WITH',
            'category_children.parent = category.id');
        $queryBuilder->leftJoin(
            'WellCommerceCategoryBundle:CategoryTranslation',
            'category_translation',
            'WITH',
            'category.id = category_translation.translatable AND category_translation.locale = :locale');
        $queryBuilder->groupBy('category.id');
        $queryBuilder->setParameter('locale', $this->getCurrentLocale());
        $query = $queryBuilder->getQuery();
        $items = $query->getArrayResult();

        $categoriesTree = [];
        foreach ($items as $item) {
            $categoriesTree[$item['id']] = [
                'id'          => $item['id'],
                'name'        => $item['name'],
                'hasChildren' => (bool)($item['children'] > 0),
{'fraction_non_alphanumeric': 0.12061880589799372, 'fraction_numerical': 0.00024172105390379503, 'mean_word_length': 2.7584014532243417, 'pattern_counts': {'":': 0, '<': 17, '<?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': '7393498', 'n_tokens_mistral': 1048, 'n_tokens_neox': 1036, 'n_words': 212}