Fixes some PHPCS

This commit is contained in:
Benoît Burnichon
2015-12-22 16:48:20 +01:00
parent bc855f200d
commit 6eba70030d
3 changed files with 20 additions and 13 deletions

View File

@@ -111,25 +111,25 @@ class RecordIndexer
public function populateIndex(BulkOperation $bulk, array $databoxes) public function populateIndex(BulkOperation $bulk, array $databoxes)
{ {
foreach ($databoxes as $databox) { foreach ($databoxes as $databox) {
$submited_records = []; $submitted_records = [];
$this->logger->info(sprintf('Indexing database %s...', $databox->get_viewname())); $this->logger->info(sprintf('Indexing database %s...', $databox->get_viewname()));
$fetcher = $this->createFetcherForDatabox($databox); // no delegate, scan the whole records $fetcher = $this->createFetcherForDatabox($databox); // no delegate, scan the whole records
// post fetch : flag records as "indexing" // post fetch : flag records as "indexing"
$fetcher->setPostFetch(function(array $records) use ($databox, $fetcher) { $fetcher->setPostFetch(function(array $records) use ($databox) {
RecordQueuer::didStartIndexingRecords($records, $databox); RecordQueuer::didStartIndexingRecords($records, $databox);
// do not restart the fetcher since it has no clause on jetons // do not restart the fetcher since it has no clause on jetons
}); });
// bulk flush : flag records as "indexed" // bulk flush : flag records as "indexed"
$bulk->onFlush(function($operation_identifiers) use ($databox, &$submited_records) { $bulk->onFlush(function($operation_identifiers) use ($databox, &$submitted_records) {
$this->onBulkFlush($databox, $operation_identifiers, $submited_records); $this->onBulkFlush($databox, $operation_identifiers, $submitted_records);
}); });
// Perform indexing // Perform indexing
$this->indexFromFetcher($bulk, $fetcher, $submited_records); $this->indexFromFetcher($bulk, $fetcher, $submitted_records);
$this->logger->info(sprintf('Finished indexing %s', $databox->get_viewname())); $this->logger->info(sprintf('Finished indexing %s', $databox->get_viewname()));
} }

View File

@@ -44,13 +44,13 @@ class RecordQueuer
} }
/** /**
* @param array $records * @param array $records
* @param $databox * @param databox $databox
* *
* nb: changing the jeton may affect a fetcher if his "where" clause (delegate) depends on jeton. * nb: changing the jeton may affect a fetcher if his "where" clause (delegate) depends on jeton.
* in this case the client of the fetcher must set a "postFetch" callback and restart the fetcher * in this case the client of the fetcher must set a "postFetch" callback and restart the fetcher
*/ */
public static function didStartIndexingRecords(array $records, $databox) public static function didStartIndexingRecords(array $records, databox $databox)
{ {
$connection = $databox->get_connection(); $connection = $databox->get_connection();
$sql = "UPDATE record SET jeton = (jeton | :flag) WHERE record_id IN (:record_ids)"; $sql = "UPDATE record SET jeton = (jeton | :flag) WHERE record_id IN (:record_ids)";
@@ -76,14 +76,14 @@ class RecordQueuer
{ {
return $connection->executeQuery($sql, array( return $connection->executeQuery($sql, array(
':flag' => $flag, ':flag' => $flag,
':record_ids' => self::array_pluck($records, 'record_id') ':record_ids' => self::arrayPluck($records, 'record_id')
), array( ), array(
':flag' => PDO::PARAM_INT, ':flag' => PDO::PARAM_INT,
':record_ids' => Connection::PARAM_INT_ARRAY ':record_ids' => Connection::PARAM_INT_ARRAY
)); ));
} }
private static function array_pluck(array $array, $key) private static function arrayPluck(array $array, $key)
{ {
$values = array(); $values = array();
foreach ($array as $item) { foreach ($array as $item) {

View File

@@ -876,10 +876,17 @@ abstract class ApiTestCase extends \PhraseanetWebTestCase
self::$DI['record_story_1']; self::$DI['record_story_1'];
self::$DI['client']->request('POST', '/api/v1/search/', $this->getParameters(['search_type' => SearchEngineOptions::RECORD_GROUPING]), [], ['HTTP_Accept' => $this->getAcceptMimeType()]); $client = $this->getClient();
$content = $this->unserialize(self::$DI['client']->getResponse()->getContent()); $client->request(
'POST',
'/api/v1/search/',
$this->getParameters(['search_type' => SearchEngineOptions::RECORD_GROUPING]),
[],
['HTTP_Accept' => $this->getAcceptMimeType()]
);
$content = $this->unserialize($client->getResponse()->getContent());
$this->evaluateResponse200(self::$DI['client']->getResponse()); $this->evaluateResponse200($client->getResponse());
$this->evaluateMeta200($content); $this->evaluateMeta200($content);
$response = $content['response']; $response = $content['response'];