Added all summit endpoint
added especialized query that returns all summits no matter if they are published or not Change-Id: I954b5640693b1537a06af259ce68401c644c2051
This commit is contained in:
parent
e480843874
commit
702e3d0a34
1
.gitignore
vendored
1
.gitignore
vendored
@ -24,3 +24,4 @@ doc/build
|
||||
.env
|
||||
storage/*
|
||||
*.log
|
||||
routes.txt
|
@ -100,6 +100,34 @@ final class OAuth2SummitApiController extends OAuth2ProtectedController
|
||||
return $this->error500($ex);
|
||||
}
|
||||
}
|
||||
|
||||
public function getAllSummits()
|
||||
{
|
||||
try {
|
||||
|
||||
$summits = [];
|
||||
|
||||
foreach($this->repository->getAllOrderedByBeginDate() as $summit){
|
||||
$summits[] = SerializerRegistry::getInstance()->getSerializer($summit)->serialize();
|
||||
}
|
||||
|
||||
$response = new PagingResponse
|
||||
(
|
||||
count($summits),
|
||||
count($summits),
|
||||
1,
|
||||
1,
|
||||
$summits
|
||||
);
|
||||
|
||||
return $this->ok($response->toArray());
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $summit_id
|
||||
* @return mixed
|
||||
|
@ -131,6 +131,10 @@ Route::group([
|
||||
|
||||
Route::get('', [ 'middleware' => 'cache:'.Config::get('cache_api_response.get_summits_response_lifetime', 600), 'uses' => 'OAuth2SummitApiController@getSummits']);
|
||||
|
||||
Route::group(array('prefix' => 'all'), function () {
|
||||
Route::get('', 'OAuth2SummitApiController@getAllSummits');
|
||||
});
|
||||
|
||||
Route::group(array('prefix' => '{id}'), function () {
|
||||
|
||||
Route::get('', [ 'middleware' => 'cache:'.Config::get('cache_api_response.get_summit_response_lifetime', 1200), 'uses' => 'OAuth2SummitApiController@getSummit'])->where('id', 'current|[0-9]+');
|
||||
|
@ -25,4 +25,9 @@ interface ISummitRepository extends IBaseRepository
|
||||
* @return Summit[]
|
||||
*/
|
||||
public function getAvailables();
|
||||
|
||||
/**
|
||||
* @return Summit[]
|
||||
*/
|
||||
public function getAllOrderedByBeginDate();
|
||||
}
|
@ -57,6 +57,19 @@ final class DoctrineSummitRepository
|
||||
->getResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Summit[]
|
||||
*/
|
||||
public function getAllOrderedByBeginDate()
|
||||
{
|
||||
return $this->getEntityManager()->createQueryBuilder()
|
||||
->select("s")
|
||||
->from(\models\summit\Summit::class, "s")
|
||||
->orderBy('s.begin_date', 'ASC')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
@ -77,6 +77,12 @@ class ApiEndpointsSeeder extends Seeder
|
||||
'http_method' => 'GET',
|
||||
'scopes' => [sprintf('%s/summits/read', $current_realm)],
|
||||
),
|
||||
array(
|
||||
'name' => 'get-all-summits',
|
||||
'route' => '/api/v1/summits/all',
|
||||
'http_method' => 'GET',
|
||||
'scopes' => [sprintf('%s/summits/read', $current_realm)],
|
||||
),
|
||||
array(
|
||||
'name' => 'get-summit',
|
||||
'route' => '/api/v1/summits/{id}',
|
||||
|
@ -37,6 +37,73 @@ final class OAuth2SummitApiTest extends ProtectedApiTest
|
||||
$this->assertResponseStatus(200);
|
||||
}
|
||||
|
||||
public function testGetAllSummits()
|
||||
{
|
||||
|
||||
$params = ['expand' => 'type'];
|
||||
|
||||
$headers = array("HTTP_Authorization" => " Bearer " . $this->access_token);
|
||||
$response = $this->action(
|
||||
"GET",
|
||||
"OAuth2SummitApiController@getAllSummits",
|
||||
$params,
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
$headers
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$summits = json_decode($content);
|
||||
$this->assertTrue(!is_null($summits));
|
||||
$this->assertResponseStatus(200);
|
||||
}
|
||||
|
||||
public function testGetSummit($summit_id = 22)
|
||||
{
|
||||
|
||||
$params = array
|
||||
(
|
||||
'expand' => 'schedule',
|
||||
'id' => $summit_id
|
||||
);
|
||||
|
||||
$headers = array("HTTP_Authorization" => " Bearer " . $this->access_token);
|
||||
$start = time();
|
||||
$response = $this->action(
|
||||
"GET",
|
||||
"OAuth2SummitApiController@getSummit",
|
||||
$params,
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
$headers
|
||||
);
|
||||
$end = time();
|
||||
$delta = $end - $start;
|
||||
echo "execution call " . $delta . " seconds ...";
|
||||
$content = $response->getContent();
|
||||
$summit = json_decode($content);
|
||||
$this->assertTrue(!is_null($summit));
|
||||
$this->assertResponseStatus(200);
|
||||
|
||||
$response = $this->action(
|
||||
"GET",
|
||||
"OAuth2SummitApiController@getSummit",
|
||||
$params,
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
$headers
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$summit = json_decode($content);
|
||||
$this->assertTrue(!is_null($summit));
|
||||
$this->assertTrue(count($summit->schedule) > 0);
|
||||
$this->assertResponseStatus(200);
|
||||
}
|
||||
|
||||
public function testGetTracks()
|
||||
{
|
||||
|
||||
@ -89,50 +156,6 @@ final class OAuth2SummitApiTest extends ProtectedApiTest
|
||||
$this->assertResponseStatus(200);
|
||||
}
|
||||
|
||||
public function testGetSummit($summit_id = 22)
|
||||
{
|
||||
|
||||
$params = array
|
||||
(
|
||||
'expand' => 'schedule',
|
||||
'id' => $summit_id
|
||||
);
|
||||
|
||||
$headers = array("HTTP_Authorization" => " Bearer " . $this->access_token);
|
||||
$start = time();
|
||||
$response = $this->action(
|
||||
"GET",
|
||||
"OAuth2SummitApiController@getSummit",
|
||||
$params,
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
$headers
|
||||
);
|
||||
$end = time();
|
||||
$delta = $end - $start;
|
||||
echo "execution call " . $delta . " seconds ...";
|
||||
$content = $response->getContent();
|
||||
$summit = json_decode($content);
|
||||
$this->assertTrue(!is_null($summit));
|
||||
$this->assertResponseStatus(200);
|
||||
|
||||
$response = $this->action(
|
||||
"GET",
|
||||
"OAuth2SummitApiController@getSummit",
|
||||
$params,
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
$headers
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$summit = json_decode($content);
|
||||
$this->assertTrue(!is_null($summit));
|
||||
$this->assertTrue(count($summit->schedule) > 0);
|
||||
$this->assertResponseStatus(200);
|
||||
}
|
||||
|
||||
public function testGetCurrentSummit($summit_id = 23)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user