<commit_before><?php

namespace Rcm\Controller;

class PageSearchApiController extends  \Rcm\Controller\BaseController
{
    function siteTitleSearchAction(){

        $query = $this->getEvent()->getRouteMatch()->getParam('query');
        $siteId = $this->getEvent()->getRouteMatch()->getParam('siteId');

        $results = $this->entityMgr->createQuery('
            select page.name from Rcm\\Entity\\PageRevision pageRevision
            join pageRevision.page page
            where (page.name like :query or pageRevision.pageTitle like :query)
        ')->setParameter('query', '%'.$query.'%')
            ->getResult();

//        $results = $this->entityMgr->createQuery('
//            select page.name from Rcm\\Entity\\PageRevision pageRevision
//            join pageRevision.page page
//            /*join page.site site*/
//            where (page.name like :query or pageRevision.pageTitle like :query)
//            /*and site.siteId = :siteId*/
//        ')->setParameter('query', '%'.$query.'%')
//        //->setParameter('siteId', '%'.$siteId.'%')
//            ->getResult();

        return new \Zend\View\Model\JsonModel($results);

    }
}<commit_msg>fix page api output format<commit_after><?php

namespace Rcm\Controller;

class PageSearchApiController extends  \Rcm\Controller\BaseController
{
    function siteTitleSearchAction(){

        $query = $this->getEvent()->getRouteMatch()->getParam('query');
        $siteId = $this->getEvent()->getRouteMatch()->getParam('siteId');

// TODO MAKE THIS RESPECT THE PROVIDED SITE ID
//        $results = $this->entityMgr->createQuery('
//            select page.name from Rcm\\Entity\\PageRevision pageRevision
//            join pageRevision.page page
//            /*join page.site site*/
//            where (page.name like :query or pageRevision.pageTitle like :query)
//            /*and site.siteId = :siteId*/
//        ')->setParameter('query', '%'.$query.'%')
//        //->setParameter('siteId', '%'.$siteId.'%')
//            ->getResult();

        $results = $this->entityMgr->createQuery('
            select page.name, pageRevision.pageTitle from Rcm\\Entity\\PageRevision pageRevision
            join pageRevision.page page
            where (page.name like :query or pageRevision.pageTitle like :query)
        ')->setParameter('query', '%'.$query.'%')
            ->getResult();

        $pageNames = array();
        foreach($results as $result){
            $pageNames[$result['name']]=$result['pageTitle'];
        }

        return new \Zend\View\Model\JsonModel($pageNames);

    }
}
{'fraction_non_alphanumeric': 0.16362931368747577, 'fraction_numerical': 0.0, 'mean_word_length': 2.4354194407456724, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, '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': '2642714', 'n_tokens_mistral': 718, 'n_tokens_neox': 697, 'n_words': 151}