From 75cc01f88a81b0147032b37eb9aab983c22ffe04 Mon Sep 17 00:00:00 2001 From: Alexander Kellner Date: Sat, 24 Feb 2024 00:24:26 +0100 Subject: [PATCH] [FEATURE] Update of Analysis/LinkClick view --- .../DataProvider/AllLinkclickDataProvider.php | 21 +++--- .../DataProvider/LinkclickDataProvider.php | 13 +--- .../Domain/Repository/AbstractRepository.php | 1 - .../Domain/Repository/LinkclickRepository.php | 18 ++---- .../Repository/LinklistenerRepository.php | 60 ++++++++++------- .../Filter/Analysis/LinkListener.html | 64 +++++++++++++------ 6 files changed, 96 insertions(+), 81 deletions(-) diff --git a/Classes/Domain/DataProvider/AllLinkclickDataProvider.php b/Classes/Domain/DataProvider/AllLinkclickDataProvider.php index 4d5f11c7..3a8c7f76 100644 --- a/Classes/Domain/DataProvider/AllLinkclickDataProvider.php +++ b/Classes/Domain/DataProvider/AllLinkclickDataProvider.php @@ -4,8 +4,7 @@ namespace In2code\Lux\Domain\DataProvider; use DateTime; -use Doctrine\DBAL\DBALException; -use Doctrine\DBAL\Driver\Exception as ExceptionDbalDriver; +use Doctrine\DBAL\Exception as ExceptionDbal; use In2code\Lux\Domain\Model\Linkclick; use In2code\Lux\Domain\Model\Pagevisit; use In2code\Lux\Domain\Model\Transfer\FilterDto; @@ -45,13 +44,12 @@ public function __construct(FilterDto $filter = null) * 'max-y' => 100 // max value for logarithmic y-axes * ] * @return void - * @throws DBALException - * @throws ExceptionDbalDriver + * @throws ExceptionDbal */ public function prepareData(): void { $intervals = $this->filter->getIntervals(); - $frequency = (string)$intervals['frequency']; + $frequency = $intervals['frequency']; $pageList = $this->getRelatedPageListToLinkclicks($intervals['intervals']); foreach ($intervals['intervals'] as $interval) { $clicks = $this->linkclickRepository->findByTimeFrame( @@ -82,8 +80,7 @@ protected function setMaxYValue(): void * @param DateTime $end * @param string $pagelist * @return int - * @throws DBALException - * @throws ExceptionDbalDriver + * @throws ExceptionDbal */ protected function getAmountOfPagevisitsInTimeframeAndPagelist( DateTime $start, @@ -93,7 +90,8 @@ protected function getAmountOfPagevisitsInTimeframeAndPagelist( $connection = DatabaseUtility::getConnectionForTable(Pagevisit::TABLE_NAME); $sql = 'select count(*) from ' . Pagevisit::TABLE_NAME . ' where crdate >= ' . $start->getTimestamp() . ' and crdate <= ' . $end->getTimestamp() - . ' and deleted=0'; + . ' and deleted=0' + . ' and site in ("' . implode('","', $this->filter->getSitesForFilter()) . '")'; if ($pagelist !== '') { $sql .= ' and page in (' . $pagelist . ')'; } @@ -105,8 +103,7 @@ protected function getAmountOfPagevisitsInTimeframeAndPagelist( * * @param array $intervals * @return string - * @throws DBALException - * @throws ExceptionDbalDriver + * @throws ExceptionDbal */ protected function getRelatedPageListToLinkclicks(array $intervals): string { @@ -117,7 +114,9 @@ protected function getRelatedPageListToLinkclicks(array $intervals): string $connection = DatabaseUtility::getConnectionForTable(Linkclick::TABLE_NAME); return (string)$connection->executeQuery( 'select group_concat(distinct page) from ' . Linkclick::TABLE_NAME - . ' where crdate >= ' . $start->getTimestamp() . ' and crdate <= ' . $end->getTimestamp() . ' and deleted=0' + . ' where crdate >= ' . $start->getTimestamp() . ' and crdate <= ' . $end->getTimestamp() + . ' and deleted=0' + . ' and site in ("' . implode('","', $this->filter->getSitesForFilter()) . '")' )->fetchOne(); } } diff --git a/Classes/Domain/DataProvider/LinkclickDataProvider.php b/Classes/Domain/DataProvider/LinkclickDataProvider.php index 4031e511..ced73d0e 100644 --- a/Classes/Domain/DataProvider/LinkclickDataProvider.php +++ b/Classes/Domain/DataProvider/LinkclickDataProvider.php @@ -3,8 +3,6 @@ declare(strict_types=1); namespace In2code\Lux\Domain\DataProvider; -use Doctrine\DBAL\DBALException; -use Doctrine\DBAL\Driver\Exception as ExceptionDbalDriver; use Doctrine\DBAL\Exception as ExceptionDbal; use In2code\Lux\Domain\Model\Linklistener; use In2code\Lux\Domain\Model\Transfer\FilterDto; @@ -48,8 +46,7 @@ public function __construct(FilterDto $filter = null) * ] * ] * @return void - * @throws DBALException - * @throws ExceptionDbalDriver + * @throws ExceptionDbal */ public function prepareData(): void { @@ -123,8 +120,7 @@ public function sortGroupedDataByPerformanceAndLimitResult(array $data, int $lim * ] * * @return array - * @throws DBALException - * @throws ExceptionDbalDriver + * @throws ExceptionDbal */ public function getGroupedData(): array { @@ -180,8 +176,7 @@ public function getGroupedData(): array * ] * * @return array - * @throws DBALException - * @throws ExceptionDbalDriver + * @throws ExceptionDbal */ protected function getUngroupedData(): array { @@ -211,8 +206,6 @@ protected function getUngroupedData(): array * @param int $pageUid * @param int $linklistener * @return int - * @throws DBALException - * @throws ExceptionDbalDriver * @throws ExceptionDbal */ protected function getPagevisitsFromPageByTagTimeframe(int $pageUid, int $linklistener): int diff --git a/Classes/Domain/Repository/AbstractRepository.php b/Classes/Domain/Repository/AbstractRepository.php index 88ffd8cc..2bd52be0 100644 --- a/Classes/Domain/Repository/AbstractRepository.php +++ b/Classes/Domain/Repository/AbstractRepository.php @@ -179,7 +179,6 @@ protected function extendWhereClauseWithFilterDomain(FilterDto $filter, string $ * @param FilterDto $filter * @param string $table table with crdate (normally the main table) * @return string - * @throws Exception */ protected function extendWhereClauseWithFilterSite(FilterDto $filter, string $table = ''): string { diff --git a/Classes/Domain/Repository/LinkclickRepository.php b/Classes/Domain/Repository/LinkclickRepository.php index 14d3d010..f71bc906 100644 --- a/Classes/Domain/Repository/LinkclickRepository.php +++ b/Classes/Domain/Repository/LinkclickRepository.php @@ -4,8 +4,6 @@ namespace In2code\Lux\Domain\Repository; use DateTime; -use Doctrine\DBAL\DBALException; -use Doctrine\DBAL\Driver\Exception as ExceptionDbalDriver; use Doctrine\DBAL\Exception as ExceptionDbal; use Exception; use In2code\Lux\Domain\Model\Linkclick; @@ -21,7 +19,6 @@ class LinkclickRepository extends AbstractRepository /** * @return int * @throws ExceptionDbal - * @throws ExceptionDbalDriver */ public function findAllAmount(): int { @@ -33,7 +30,6 @@ public function findAllAmount(): int * @param int $linklistener * @return int * @throws ExceptionDbal - * @throws ExceptionDbalDriver */ public function getFirstCreationDateFromLinklistenerIdentifier(int $linklistener): int { @@ -52,7 +48,6 @@ public function getFirstCreationDateFromLinklistenerIdentifier(int $linklistener * @param int $linklistener * @return int * @throws ExceptionDbal - * @throws ExceptionDbalDriver */ public function getLatestCreationDateFromLinklistenerIdentifier(int $linklistener): int { @@ -88,8 +83,7 @@ public function getLatestCreationDateFromLinklistenerIdentifier(int $linklistene * ] * @param FilterDto $filter * @return array - * @throws DBALException - * @throws ExceptionDbalDriver + * @throws ExceptionDbal */ public function getAmountOfLinkclicksGroupedByPageUid(FilterDto $filter): array { @@ -100,6 +94,7 @@ public function getAmountOfLinkclicksGroupedByPageUid(FilterDto $filter): array . ' where ' . $this->extendWhereClauseWithFilterTime($filter, false, 'lc'); $sql .= $this->extendWhereClauseWithFilterSearchterms($filter, 'll'); $sql .= $this->extendWhereClauseWithFilterCategoryScoring($filter, 'll'); + $sql .= $this->extendWhereClauseWithFilterSite($filter, 'lc'); $sql .= ' group by lc.linklistener, lc.page'; return $connection->executeQuery($sql)->fetchAllAssociative(); } @@ -120,9 +115,7 @@ public function getAmountOfLinkclicksGroupedByPageUid(FilterDto $filter): array * ] * @param int $linklistener * @return array - * @throws DBALException * @throws Exception - * @throws ExceptionDbalDriver */ public function getAmountOfLinkclicksByLinklistenerGroupedByPageUid(int $linklistener): array { @@ -139,7 +132,6 @@ public function getAmountOfLinkclicksByLinklistenerGroupedByPageUid(int $linklis * @return int * @throws ExceptionDbal * @throws Exception - * @throws ExceptionDbalDriver */ public function getAmountOfLinkclicksByPageIdentifierAndTimeframe(int $pageIdentifier, FilterDto $filter): int { @@ -156,7 +148,6 @@ public function getAmountOfLinkclicksByPageIdentifierAndTimeframe(int $pageIdent * @param int $page * @return DateTime * @throws Exception - * @throws ExceptionDbalDriver */ public function findLastDateByLinklistenerAndPage(int $linklistener, int $page): DateTime { @@ -193,7 +184,6 @@ public function findByLinklistenerIdentifier(int $linklistenerIdentifier, int $l * @param int $linklistener * @return array * @throws ExceptionDbal - * @throws ExceptionDbalDriver */ public function findRawByLinklistenerIdentifier(int $linklistener): array { @@ -211,8 +201,7 @@ public function findRawByLinklistenerIdentifier(int $linklistener): array * @param DateTime $end * @param FilterDto|null $filter * @return int - * @throws DBALException - * @throws ExceptionDbalDriver + * @throws ExceptionDbal */ public function findByTimeFrame(DateTime $start, DateTime $end, FilterDto $filter = null): int { @@ -223,6 +212,7 @@ public function findByTimeFrame(DateTime $start, DateTime $end, FilterDto $filte . ' where lc.crdate >= ' . $start->getTimestamp() . ' and lc.crdate <= ' . $end->getTimestamp(); $sql .= $this->extendWhereClauseWithFilterSearchterms($filter, 'll'); $sql .= $this->extendWhereClauseWithFilterCategoryScoring($filter, 'll'); + $sql .= $this->extendWhereClauseWithFilterSite($filter, 'lc'); return (int)$connection->executeQuery($sql)->fetchOne(); } } diff --git a/Classes/Domain/Repository/LinklistenerRepository.php b/Classes/Domain/Repository/LinklistenerRepository.php index c51d00a1..0009046b 100644 --- a/Classes/Domain/Repository/LinklistenerRepository.php +++ b/Classes/Domain/Repository/LinklistenerRepository.php @@ -23,46 +23,58 @@ class LinklistenerRepository extends AbstractRepository public function findByFilter(FilterDto $filter): QueryResultInterface { $query = $this->createQuery(); - $logicalAnd = [$query->greaterThan('uid', 0)]; - if ($filter->isSet()) { - $logicalAnd[] = $query->greaterThan('linkclicks.crdate', $filter->getStartTimeForFilter()); - $logicalAnd[] = $query->lessThan('linkclicks.crdate', $filter->getEndTimeForFilter()); - } - $logicalAnd = $this->extendWithExtendedFilterQuery($query, $logicalAnd, $filter); + $logicalAnd = $this->extendLogicalAndWithFilterConstraintsForCrdate($filter, $query, []); + $logicalAnd = $this->extendWithExtendedFilterQuery($filter, $query, $logicalAnd); $query->matching($query->logicalAnd(...$logicalAnd)); return $query->execute(); } /** + * @param FilterDto $filter + * @param QueryInterface $query + * @param array $logicalAnd + * @return array + * @throws InvalidQueryException + */ + protected function extendLogicalAndWithFilterConstraintsForCrdate( + FilterDto $filter, + QueryInterface $query, + array $logicalAnd + ): array { + $logicalAnd[] = $query->greaterThan('linkclicks.crdate', $filter->getStartTimeForFilter()); + $logicalAnd[] = $query->lessThan('linkclicks.crdate', $filter->getEndTimeForFilter()); + return $logicalAnd; + } + + /** + * @param FilterDto $filter * @param QueryInterface $query * @param array $logicalAnd - * @param FilterDto|null $filter * @return array * @throws InvalidQueryException */ protected function extendWithExtendedFilterQuery( + FilterDto $filter, QueryInterface $query, - array $logicalAnd, - FilterDto $filter = null + array $logicalAnd ): array { - if ($filter !== null) { - if ($filter->isSearchtermSet()) { - $logicalOr = []; - foreach ($filter->getSearchterms() as $searchterm) { - if (MathUtility::canBeInterpretedAsInteger($searchterm)) { - $logicalOr[] = $query->equals('uid', $searchterm); - } else { - $logicalOr[] = $query->like('title', '%' . $searchterm . '%'); - $logicalOr[] = $query->like('description', '%' . $searchterm . '%'); - $logicalOr[] = $query->like('category.title', '%' . $searchterm . '%'); - } + if ($filter->isSearchtermSet()) { + $logicalOr = []; + foreach ($filter->getSearchterms() as $searchterm) { + if (MathUtility::canBeInterpretedAsInteger($searchterm)) { + $logicalOr[] = $query->equals('uid', $searchterm); + } else { + $logicalOr[] = $query->like('title', '%' . $searchterm . '%'); + $logicalOr[] = $query->like('description', '%' . $searchterm . '%'); + $logicalOr[] = $query->like('category.title', '%' . $searchterm . '%'); } - $logicalAnd[] = $query->logicalOr(...$logicalOr); - } - if ($filter->isCategoryScoringSet()) { - $logicalAnd[] = $query->equals('category', $filter->getCategoryScoring()); } + $logicalAnd[] = $query->logicalOr(...$logicalOr); + } + if ($filter->isCategoryScoringSet()) { + $logicalAnd[] = $query->equals('category', $filter->getCategoryScoring()); } + $logicalAnd[] = $query->in('linkclicks.site', $filter->getSitesForFilter()); return $logicalAnd; } } diff --git a/Resources/Private/Partials/Filter/Analysis/LinkListener.html b/Resources/Private/Partials/Filter/Analysis/LinkListener.html index 1fed7867..f7010d2c 100644 --- a/Resources/Private/Partials/Filter/Analysis/LinkListener.html +++ b/Resources/Private/Partials/Filter/Analysis/LinkListener.html @@ -4,22 +4,43 @@

Filter

-
-
+
+
Suche
+ type="text" + property="searchterm" + id="searchterm" + class="form-control" + placeholder="{f:translate(key:'LLL:EXT:lux/Resources/Private/Language/locallang_db.xlf:module.list.filter.searchterm')}" />
+
+ + +
+
+ + +
+
Zeit
+
+ + +
-
+
Category
@@ -50,21 +82,11 @@
- -
- - -
+
- -
+
+
This submit is not visible. Nevertheless it will be triggered when pressing return in an input field because it is the first submit.