<commit_before><?php
namespace MapasCulturais\Repositories;
use MapasCulturais\Traits;
use MapasCulturais\Entities\ProjectOpportunity;
use MapasCulturais\Entities\Project;

class Opportunity extends \MapasCulturais\Repository{
    use Traits\RepositoryKeyword,
        Traits\RepositoryAgentRelation;


    function findByProjectAndOpportunityMeta($project, $key, $value) {
        try {
            $query = $this->_em->createQuery("
            SELECT 
                po
            FROM
                MapasCulturais\Entities\OpportunityMeta om
                JOIN MapasCulturais\Entities\ProjectOpportunity po WITH om.owner=po
                JOIN po.ownerEntity oe
                WHERE om.key=:key AND om.value=:value AND oe.id=:projectId
            ");
        
            $params = [
                'projectId' => $project->id,
                'key'=>$key,
                'value'=>$value
            ];

            $query->setParameters($params);

            return $query->getResult();<commit_msg>refatora findByProjectAndOpportunityMeta , agora utilizando o metodo getChildrenIds<commit_after><?php
namespace MapasCulturais\Repositories;
use MapasCulturais\Traits;
use MapasCulturais\Entities\ProjectOpportunity;
use MapasCulturais\Entities\Project;

class Opportunity extends \MapasCulturais\Repository{
    use Traits\RepositoryKeyword,
        Traits\RepositoryAgentRelation;


    function findByProjectAndOpportunityMeta(Project $project, $key, $value) {
        $projectsIds = $project->getChildrenIds();
        $projectsIds[] = $project->id;

        try {
            $query = $this->_em->createQuery("
            SELECT 
                po
            FROM
                MapasCulturais\Entities\OpportunityMeta om
                JOIN MapasCulturais\Entities\ProjectOpportunity po WITH om.owner=po
                JOIN po.ownerEntity oe
                WHERE om.key=:key AND om.value=:value AND oe.id in (:projectsIds)
            ");
        
            $params = [
                'projectsIds' => $projectsIds,
                'key'=>$key,
                'value'=>$value
            ];

            $query->setParameters($params);

            return $query->getResult();
{'fraction_non_alphanumeric': 0.09420289855072464, 'fraction_numerical': 0.0, 'mean_word_length': 2.0553250345781464, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 20, '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': '4046735', 'n_tokens_mistral': 627, 'n_tokens_neox': 610, 'n_words': 112}