Added filter by full_name to speakers

Change-Id: I365ed596b6c6fe47139b895d2bf042123bc2815c
This commit is contained in:
smarcet
2019-08-05 17:54:26 -03:00
parent cbaec02833
commit 187f1e2658
7 changed files with 80 additions and 41 deletions

View File

@@ -951,7 +951,7 @@ final class OAuth2SummitEventsApiController extends OAuth2ProtectedController
$order = Request::input('order', '');
$filter = Request::input('filter', '');
$serializer_type = SerializerRegistry::SerializerType_Public;
if(strstr($order, "trackchairsel") !== false || strstr($filter, "selection_status") !== false ){
if(strstr($order, "trackchairsel") !== false){
$serializer_type = SerializerRegistry::SerializerType_Private;
}
$response = $strategy->getEvents(['summit_id' => $summit_id]);

View File

@@ -240,6 +240,7 @@ final class OAuth2SummitSpeakersApiController extends OAuth2ProtectedController
'first_name' => ['=@', '=='],
'last_name' => ['=@', '=='],
'full_name' => ['=@', '=='],
'email' => ['=@', '=='],
'id' => ['=='],
]);

View File

@@ -59,7 +59,7 @@ final class DoctrineTagRepository
->from(\models\main\Tag::class, "t")
->where('UPPER(TRIM(t.tag)) = UPPER(TRIM(:tag))')
->setParameter('tag', $tag)
->getQuery()->getSingleResult();
->getQuery()->getFirstResult();
}
catch(NoResultException $e){
return null;

View File

@@ -67,6 +67,7 @@ final class DoctrineSpeakerRepository
'email' => 'Email',
'first_name' => 'FirstName',
'last_name' => 'LastName',
'full_name' => 'FullName',
));
}
@@ -76,7 +77,8 @@ FROM (
SELECT S.ID,
IFNULL(S.FirstName, M.FirstName) AS FirstName,
IFNULL(S.LastName, M.Surname) AS LastName,
IFNULL(M.Email, R.Email) AS Email
CONCAT(IFNULL(S.FirstName, M.FirstName), ' ', IFNULL(S.LastName, M.Surname)) AS FullName,
IFNULL(M.Email, R.Email) AS Email,
FROM PresentationSpeaker S
LEFT JOIN Member M ON M.ID = S.MemberID
LEFT JOIN SpeakerRegistrationRequest R ON R.SpeakerID = S.ID
@@ -92,6 +94,7 @@ FROM (
SELECT S.ID,
IFNULL(S.FirstName, M.FirstName) AS FirstName,
IFNULL(S.LastName, M.Surname) AS LastName,
CONCAT(IFNULL(S.FirstName, M.FirstName), ' ', IFNULL(S.LastName, M.Surname)) AS FullName,
IFNULL(M.Email, R.Email) AS Email
FROM PresentationSpeaker S
LEFT JOIN Member M ON M.ID = S.MemberID
@@ -108,6 +111,7 @@ FROM (
SELECT S.ID,
IFNULL(S.FirstName, M.FirstName) AS FirstName,
IFNULL(S.LastName, M.Surname) AS LastName,
CONCAT(IFNULL(S.FirstName, M.FirstName), ' ', IFNULL(S.LastName, M.Surname)) AS FullName,
IFNULL(M.Email, R.Email) AS Email
FROM PresentationSpeaker S
LEFT JOIN Member M ON M.ID = S.MemberID
@@ -124,6 +128,7 @@ FROM (
SELECT S.ID,
IFNULL(S.FirstName, M.FirstName) AS FirstName,
IFNULL(S.LastName, M.Surname) AS LastName,
CONCAT(IFNULL(S.FirstName, M.FirstName), ' ', IFNULL(S.LastName, M.Surname)) AS FullName,
IFNULL(M.Email, R.Email) AS Email
FROM PresentationSpeaker S
LEFT JOIN Member M ON M.ID = S.MemberID
@@ -171,6 +176,7 @@ FROM (
S.TwitterName,
IFNULL(S.FirstName, M.FirstName) AS FirstName,
IFNULL(S.LastName, M.Surname) AS LastName,
CONCAT(IFNULL(S.FirstName, M.FirstName), ' ', IFNULL(S.LastName, M.Surname)) AS FullName,
IFNULL(M.Email,R.Email) AS Email,
S.PhotoID
FROM PresentationSpeaker S
@@ -204,6 +210,40 @@ FROM (
S.TwitterName,
IFNULL(S.FirstName, M.FirstName) AS FirstName,
IFNULL(S.LastName, M.Surname) AS LastName,
CONCAT(IFNULL(S.FirstName, M.FirstName), ' ', IFNULL(S.LastName, M.Surname)) AS FullName,
IFNULL(M.Email,R.Email) AS Email,
S.PhotoID
FROM PresentationSpeaker S
LEFT JOIN Member M ON M.ID = S.MemberID
LEFT JOIN SpeakerRegistrationRequest R ON R.SpeakerID = S.ID
WHERE
EXISTS
(
SELECT E.ID FROM SummitEvent E
INNER JOIN Presentation P ON E.ID = P.ID
INNER JOIN Presentation_Speakers PS ON PS.PresentationID = P.ID
WHERE E.SummitID = {$summit->getId()} AND P.ModeratorID = S.ID
)
UNION
SELECT
S.ID,
S.ClassName,
S.Created,
S.LastEdited,
S.Title AS SpeakerTitle,
S.Bio,
S.IRCHandle,
S.AvailableForBureau,
S.FundedTravel,
S.Country,
S.MemberID,
S.WillingToTravel,
S.WillingToPresentVideo,
S.Notes,
S.TwitterName,
IFNULL(S.FirstName, M.FirstName) AS FirstName,
IFNULL(S.LastName, M.Surname) AS LastName,
CONCAT(IFNULL(S.FirstName, M.FirstName), ' ', IFNULL(S.LastName, M.Surname)) AS FullName,
IFNULL(M.Email,R.Email) AS Email,
S.PhotoID
FROM PresentationSpeaker S
@@ -237,38 +277,7 @@ FROM (
IFNULL(S.FirstName, M.FirstName) AS FirstName,
IFNULL(S.LastName, M.Surname) AS LastName,
IFNULL(M.Email,R.Email) AS Email,
S.PhotoID
FROM PresentationSpeaker S
LEFT JOIN Member M ON M.ID = S.MemberID
LEFT JOIN SpeakerRegistrationRequest R ON R.SpeakerID = S.ID
WHERE
EXISTS
(
SELECT E.ID FROM SummitEvent E
INNER JOIN Presentation P ON E.ID = P.ID
INNER JOIN Presentation_Speakers PS ON PS.PresentationID = P.ID
WHERE E.SummitID = {$summit->getId()} AND P.ModeratorID = S.ID
)
UNION
SELECT
S.ID,
S.ClassName,
S.Created,
S.LastEdited,
S.Title AS SpeakerTitle,
S.Bio,
S.IRCHandle,
S.AvailableForBureau,
S.FundedTravel,
S.Country,
S.MemberID,
S.WillingToTravel,
S.WillingToPresentVideo,
S.Notes,
S.TwitterName,
IFNULL(S.FirstName, M.FirstName) AS FirstName,
IFNULL(S.LastName, M.Surname) AS LastName,
IFNULL(M.Email,R.Email) AS Email,
CONCAT(IFNULL(S.FirstName, M.FirstName), ' ', IFNULL(S.LastName, M.Surname)) AS FullName,
S.PhotoID
FROM PresentationSpeaker S
LEFT JOIN Member M ON M.ID = S.MemberID
@@ -332,11 +341,11 @@ SQL;
if(!is_null($filter))
{
$where_conditions = $filter->toRawSQL([
'first_name' => 'FirstName',
'last_name' => 'LastName',
'email' => 'Email',
'id' => 'ID'
'id' => 'ID',
'full_name' => "FullName",
]);
if(!empty($where_conditions)) {
$extra_filters = " WHERE {$where_conditions}";
@@ -361,6 +370,7 @@ FROM (
SELECT S.ID,
IFNULL(S.FirstName, M.FirstName) AS FirstName,
IFNULL(S.LastName, M.Surname) AS LastName,
CONCAT(IFNULL(S.FirstName, M.FirstName), ' ', IFNULL(S.LastName, M.Surname)) AS FullName,
IFNULL(M.Email,R.Email) AS Email
FROM PresentationSpeaker S
LEFT JOIN Member M ON M.ID = S.MemberID
@@ -403,6 +413,7 @@ FROM (
IFNULL(S.FirstName, M.FirstName) AS FirstName,
IFNULL(S.LastName, M.Surname) AS LastName,
IFNULL(M.Email,R.Email) AS Email,
CONCAT(IFNULL(S.FirstName, M.FirstName), ' ', IFNULL(S.LastName, M.Surname)) AS FullName,
S.PhotoID
FROM PresentationSpeaker S
LEFT JOIN Member M ON M.ID = S.MemberID

View File

@@ -192,8 +192,7 @@ final class DoctrineSummitEventRepository
|| $filter->hasFilter('speaker_id')
|| $filter->hasFilter('selection_status')
|| $filter->hasFilter('speaker_email')
|| $order->hasOrder('trackchairsel')
?
|| (!is_null($order) && $order->hasOrder('trackchairsel'))?
\models\summit\Presentation::class:
\models\summit\SummitEvent::class;

View File

@@ -521,7 +521,34 @@ final class OAuth2SummitApiTest extends ProtectedApiTest
$headers = array("HTTP_Authorization" => " Bearer " . $this->access_token);
$response = $this->action(
"GET",
"OAuth2SummitSpeakersApiController@getAllSpeakers",
"OAuth2SummitSpeakersApiController@getAll",
$params,
array(),
array(),
array(),
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(200);
$speakers = json_decode($content);
$this->assertTrue(!is_null($speakers));
}
public function testAllSpeakersFilterByFullName()
{
$params = [
'page' => 1,
'per_page' => 15,
'filter' => 'full_name=@Bryce',
'order' => '+first_name,-last_name'
];
$headers = array("HTTP_Authorization" => " Bearer " . $this->access_token);
$response = $this->action(
"GET",
"OAuth2SummitSpeakersApiController@getAll",
$params,
array(),
array(),

View File

@@ -895,7 +895,8 @@ final class OAuth2SummitEventsApiTest extends ProtectedApiTest
'order' => '+trackchairsel',
'filter' =>
[
'selection_status==alternate',
'track_id==314',
'selection_status==accepted',
],
'expand' => 'speakers',
];