mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-14 05:23:21 +00:00
Move engine query log process from search engine classes to controllers
This commit is contained in:
@@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Controller\Client;
|
||||
|
||||
use Alchemy\Phrasea\SearchEngine\SearchEngineOptions;
|
||||
use Alchemy\Phrasea\Exception\SessionNotFound;
|
||||
use Entities\UserQuery;
|
||||
use Silex\Application;
|
||||
use Silex\ControllerProviderInterface;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
@@ -150,6 +151,19 @@ class Root implements ControllerProviderInterface
|
||||
|
||||
$result = $app['phraseanet.SE']->query($query, $currentPage, $perPage);
|
||||
|
||||
if (null !== $user = $app['authentication']->getUser()) {
|
||||
$userQuery = new UserQuery();
|
||||
$userQuery->setUsrId($user->get_id());
|
||||
$userQuery->setQuery($query);
|
||||
|
||||
$app['EM']->persist($userQuery);
|
||||
$app['EM']->flush();
|
||||
|
||||
if ($user->getPrefs('start_page') === 'LAST_QUERY') {
|
||||
$user->setPrefs('start_page_query', $query);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($options->getDataboxes() as $databox) {
|
||||
$colls = array_map(function(\collection $collection) {
|
||||
return $collection->get_coll_id();
|
||||
|
@@ -12,6 +12,7 @@
|
||||
namespace Alchemy\Phrasea\Controller\Prod;
|
||||
|
||||
use Alchemy\Phrasea\SearchEngine\SearchEngineOptions;
|
||||
use Entities\UserQuery;
|
||||
use Silex\Application;
|
||||
use Silex\ControllerProviderInterface;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
@@ -118,6 +119,17 @@ class Query implements ControllerProviderInterface
|
||||
|
||||
$result = $app['phraseanet.SE']->query($query, (($page - 1) * $perPage), $perPage);
|
||||
|
||||
$userQuery = new UserQuery();
|
||||
$userQuery->setUsrId($app['authentication']->getUser()->get_id());
|
||||
$userQuery->setQuery($result->getQuery());
|
||||
|
||||
$app['EM']->persist($userQuery);
|
||||
$app['EM']->flush();
|
||||
|
||||
if ($app['authentication']->getUser()->getPrefs('start_page') === 'LAST_QUERY') {
|
||||
$app['authentication']->getUser()->setPrefs('start_page_query', $result->getQuery());
|
||||
}
|
||||
|
||||
foreach ($options->getDataboxes() as $databox) {
|
||||
$colls = array_map(function(\collection $collection) {
|
||||
return $collection->get_coll_id();
|
||||
|
@@ -18,7 +18,6 @@ use Alchemy\Phrasea\SearchEngine\SearchEngineResult;
|
||||
use Alchemy\Phrasea\SearchEngine\SearchEngineSuggestion;
|
||||
use Alchemy\Phrasea\Exception\RuntimeException;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Entities\UserQuery;
|
||||
|
||||
class PhraseaEngine implements SearchEngineInterface
|
||||
{
|
||||
@@ -576,19 +575,6 @@ class PhraseaEngine implements SearchEngineInterface
|
||||
$stmt->execute($params);
|
||||
$stmt->closeCursor();
|
||||
|
||||
if (null !== $user = $this->app['authentication']->getUser()) {
|
||||
$userQuery = new UserQuery();
|
||||
$userQuery->setUsrId($user->get_id());
|
||||
$userQuery->setQuery($query);
|
||||
|
||||
$this->app['EM']->persist($userQuery);
|
||||
$this->app['EM']->flush();
|
||||
|
||||
if ($user->getPrefs('start_page') === 'LAST_QUERY') {
|
||||
$user->setPrefs('start_page_query', $query);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@@ -101,4 +101,12 @@ class UserQuery
|
||||
{
|
||||
return $this->created;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $created
|
||||
*/
|
||||
public function setCreated(\DateTime $created)
|
||||
{
|
||||
$this->created = $created;
|
||||
}
|
||||
}
|
||||
|
@@ -14,6 +14,7 @@ use Alchemy\Phrasea\Application;
|
||||
use Alchemy\Phrasea\Border\File;
|
||||
use Alchemy\Phrasea\Border\Attribute\Status;
|
||||
use Alchemy\Phrasea\Border\Manager as BorderManager;
|
||||
use Entities\UserQuery;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
@@ -895,6 +896,13 @@ class API_V1_adapter extends API_V1_Abstract
|
||||
|
||||
$search_result = $this->app['phraseanet.SE']->query($query, $offsetStart, $perPage);
|
||||
|
||||
$userQuery = new UserQuery();
|
||||
$userQuery->setUsrId($this->app['authentication']->getUser()->get_id());
|
||||
$userQuery->setQuery($query);
|
||||
|
||||
$this->app['EM']->persist($userQuery);
|
||||
$this->app['EM']->flush();
|
||||
|
||||
foreach ($options->getDataboxes() as $databox) {
|
||||
$colls = array_map(function(\collection $collection) {
|
||||
return $collection->get_coll_id();
|
||||
|
Reference in New Issue
Block a user