diff --git a/Classes/Controller/LeadController.php b/Classes/Controller/LeadController.php index df57fd99..f5371914 100644 --- a/Classes/Controller/LeadController.php +++ b/Classes/Controller/LeadController.php @@ -247,6 +247,7 @@ public function companiesDisabledAction(string $tokenWiredminds = ''): ResponseI * @return ResponseInterface * @throws InvalidConfigurationTypeException * @throws InvalidQueryException + * @throws AuthenticationException */ public function companyAction(Company $company): ResponseInterface { @@ -260,7 +261,7 @@ public function companyAction(Company $company): ResponseInterface $this->view->assignMultiple([ 'company' => $company, 'categories' => $this->categoryRepository->findAllLuxCompanyCategories(), - 'interestingLogs' => $this->logRepository->findInterestingLogsByCompany($company), + 'interestingLogs' => $this->logRepository->findInterestingLogsByCompany($company, $filter->setLimit(250)), 'scoringWeeks' => GeneralUtility::makeInstance(CompanyScoringWeeksDataProvider::class, $filter), 'categoryScorings' => GeneralUtility::makeInstance(CompanyCategoryScoringsDataProvider::class, $filter), 'numberOfVisitorsData' => GeneralUtility::makeInstance(PagevisistsDataProvider::class, $filter), diff --git a/Classes/Domain/Repository/LogRepository.php b/Classes/Domain/Repository/LogRepository.php index 34779728..fadf6fc5 100644 --- a/Classes/Domain/Repository/LogRepository.php +++ b/Classes/Domain/Repository/LogRepository.php @@ -51,18 +51,19 @@ public function findInterestingLogs(FilterDto $filter): QueryResultInterface /** * @param Company $company - * @param int $limit + * @param FilterDto $filter * @return QueryResultInterface * @throws InvalidConfigurationTypeException * @throws InvalidQueryException */ - public function findInterestingLogsByCompany(Company $company, int $limit = 250): QueryResultInterface + public function findInterestingLogsByCompany(Company $company, FilterDto $filter): QueryResultInterface { $query = $this->createQuery(); $logicalAnd = $this->interestingLogsLogicalAnd($query); $logicalAnd[] = $query->equals('visitor.companyrecord', $company); + $logicalAnd = $this->extendLogicalAndWithFilterConstraintsForSite($filter, $query, $logicalAnd); $query->matching($query->logicalAnd(...$logicalAnd)); - $query->setLimit($limit); + $query->setLimit($filter->getLimit()); return $query->execute(); } diff --git a/Classes/Domain/Repository/VisitorRepository.php b/Classes/Domain/Repository/VisitorRepository.php index 496607bb..a9180417 100644 --- a/Classes/Domain/Repository/VisitorRepository.php +++ b/Classes/Domain/Repository/VisitorRepository.php @@ -26,6 +26,7 @@ use In2code\Lux\Utility\ArrayUtility; use In2code\Lux\Utility\DatabaseUtility; use In2code\Lux\Utility\DateUtility; +use In2code\Lux\Utility\ObjectUtility; use In2code\Lux\Utility\StringUtility; use TYPO3\CMS\Core\Utility\MathUtility; use TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException; @@ -547,9 +548,13 @@ public function getScoringSumFromCompany(Company $company): int public function findByCompany(Company $company, int $limit = 200): array { $connection = DatabaseUtility::getConnectionForTable(Visitor::TABLE_NAME); - $sql = 'select uid,scoring from ' . Visitor::TABLE_NAME - . ' where deleted=0 and blacklisted=0 and companyrecord = ' . $company->getUid() - . ' order by identified desc, scoring desc limit ' . $limit; + $sql = 'select v.uid,v.scoring from ' . Visitor::TABLE_NAME . ' v' + . ' left join ' . Pagevisit::TABLE_NAME . ' pv on v.uid = pv.visitor' + . ' where v.deleted=0 and v.blacklisted=0 and v.companyrecord = ' . $company->getUid() + . $this->extendWhereClauseWithFilterSite(ObjectUtility::getFilterDto(), 'pv') + . ' group by v.uid,v.scoring' + . ' order by v.identified desc, v.scoring desc' + . ' limit ' . $limit; $results = $connection->executeQuery($sql)->fetchAllAssociative(); $visitors = []; diff --git a/Resources/Private/Partials/Box/Company/Visitors.html b/Resources/Private/Partials/Box/Company/Visitors.html index d7800e69..d7305a0b 100644 --- a/Resources/Private/Partials/Box/Company/Visitors.html +++ b/Resources/Private/Partials/Box/Company/Visitors.html @@ -2,7 +2,7 @@