Moderators query bug
the moderators query was doing inner join with presentations, so if was returning the wrong moderators resulset. Change-Id: I39ac3076e5b475289d3b5b57e523a3fb816aa9b7
This commit is contained in:
parent
4df335fdf9
commit
c34ef254b7
@ -13,6 +13,7 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
use Doctrine\Common\Collections\Criteria;
|
use Doctrine\Common\Collections\Criteria;
|
||||||
|
use Doctrine\ORM\Query\ResultSetMappingBuilder;
|
||||||
use models\main\File;
|
use models\main\File;
|
||||||
use models\main\Member;
|
use models\main\Member;
|
||||||
use models\utils\SilverstripeBaseModel;
|
use models\utils\SilverstripeBaseModel;
|
||||||
@ -670,15 +671,27 @@ class Summit extends SilverstripeBaseModel
|
|||||||
/**
|
/**
|
||||||
* @return \Doctrine\ORM\QueryBuilder
|
* @return \Doctrine\ORM\QueryBuilder
|
||||||
*/
|
*/
|
||||||
private function buildModeratorsQuery(){
|
private function buildModeratorsQuery()
|
||||||
return $this->createQueryBuilder()
|
{
|
||||||
->select('distinct ps')
|
$query = <<<SQL
|
||||||
->from('models\summit\PresentationSpeaker','ps')
|
SELECT DISTINCT p0_.FirstName , p0_.LastName,
|
||||||
->join('ps.presentations','p')
|
p0_.Title , p0_.Bio , p0_.IRCHandle,
|
||||||
->join('p.summit','s')
|
p0_.TwitterName ,
|
||||||
->join('p.moderator','m')
|
p0_.ID , p0_.Created, p0_.LastEdited,
|
||||||
->where('s.id = :summit_id and p.published = 1 and m.id = ps.id')
|
p0_.PhotoID,
|
||||||
->setParameter('summit_id', $this->getId());
|
p0_.MemberID
|
||||||
|
FROM PresentationSpeaker p0_
|
||||||
|
|
||||||
|
WHERE p0_.ID IN (
|
||||||
|
SELECT Presentation.ModeratorID FROM Presentation INNER JOIN SummitEvent ON SummitEvent.ID = Presentation.ID
|
||||||
|
WHERE SummitID = {$this->getId()} AND Published = 1
|
||||||
|
)
|
||||||
|
SQL;
|
||||||
|
$rsm = new ResultSetMappingBuilder($this->getEM());
|
||||||
|
$rsm->addRootEntityFromClassMetadata(\models\summit\PresentationSpeaker::class, 's', []);
|
||||||
|
// build rsm here
|
||||||
|
$native_query = $this->getEM()->createNativeQuery($query, $rsm);
|
||||||
|
return $native_query;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -699,7 +712,7 @@ class Summit extends SilverstripeBaseModel
|
|||||||
*/
|
*/
|
||||||
public function getSpeakers(){
|
public function getSpeakers(){
|
||||||
// moderators
|
// moderators
|
||||||
$moderators = $this->buildModeratorsQuery()->getQuery()->getResult();
|
$moderators = $this->buildModeratorsQuery()->getResult();
|
||||||
// get moderators ids to exclude from speakers
|
// get moderators ids to exclude from speakers
|
||||||
$moderators_ids = array();
|
$moderators_ids = array();
|
||||||
foreach($moderators as $m){
|
foreach($moderators as $m){
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityManager;
|
||||||
use Doctrine\ORM\Mapping AS ORM;
|
use Doctrine\ORM\Mapping AS ORM;
|
||||||
use Doctrine\ORM\NativeQuery;
|
use Doctrine\ORM\NativeQuery;
|
||||||
use Doctrine\ORM\Query;
|
use Doctrine\ORM\Query;
|
||||||
@ -118,5 +119,12 @@ class SilverstripeBaseModel implements IEntity
|
|||||||
return Registry::getManager(self::EntityManager)->getConnection()->prepare($sql);
|
return Registry::getManager(self::EntityManager)->getConnection()->prepare($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return EntityManager
|
||||||
|
*/
|
||||||
|
protected function getEM(){
|
||||||
|
return Registry::getManager(self::EntityManager);
|
||||||
|
}
|
||||||
|
|
||||||
const EntityManager = 'ss';
|
const EntityManager = 'ss';
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user