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)
{
foreach ($databoxes as $databox) {
$submited_records = [];
$submitted_records = [];
$this->logger->info(sprintf('Indexing database %s...', $databox->get_viewname()));
$fetcher = $this->createFetcherForDatabox($databox); // no delegate, scan the whole records
// 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);
// do not restart the fetcher since it has no clause on jetons
});
// bulk flush : flag records as "indexed"
$bulk->onFlush(function($operation_identifiers) use ($databox, &$submited_records) {
$this->onBulkFlush($databox, $operation_identifiers, $submited_records);
$bulk->onFlush(function($operation_identifiers) use ($databox, &$submitted_records) {
$this->onBulkFlush($databox, $operation_identifiers, $submitted_records);
});
// Perform indexing
$this->indexFromFetcher($bulk, $fetcher, $submited_records);
$this->indexFromFetcher($bulk, $fetcher, $submitted_records);
$this->logger->info(sprintf('Finished indexing %s', $databox->get_viewname()));
}

View File

@@ -44,13 +44,13 @@ class RecordQueuer
}
/**
* @param array $records
* @param $databox
* @param array $records
* @param databox $databox
*
* 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
*/
public static function didStartIndexingRecords(array $records, $databox)
public static function didStartIndexingRecords(array $records, databox $databox)
{
$connection = $databox->get_connection();
$sql = "UPDATE record SET jeton = (jeton | :flag) WHERE record_id IN (:record_ids)";
@@ -76,14 +76,14 @@ class RecordQueuer
{
return $connection->executeQuery($sql, array(
':flag' => $flag,
':record_ids' => self::array_pluck($records, 'record_id')
':record_ids' => self::arrayPluck($records, 'record_id')
), array(
':flag' => PDO::PARAM_INT,
':record_ids' => Connection::PARAM_INT_ARRAY
));
}
private static function array_pluck(array $array, $key)
private static function arrayPluck(array $array, $key)
{
$values = array();
foreach ($array as $item) {

View File

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