From 95b83665437320fa88c598ccc420c0163fbd9872 Mon Sep 17 00:00:00 2001 From: Alexander Kellner Date: Sat, 19 Aug 2023 16:46:05 +0200 Subject: [PATCH 1/2] [FEATURE] Make leads per time visible This is important to get a feeling how much you would have to pay for the WiredMinds service if you would choose it. Related: https://projekte.in2code.de/issues/58722 --- Classes/Controller/LeadController.php | 2 + .../DataProvider/AbstractDataProvider.php | 8 +-- .../DataProvider/LeadsPerTimeDataProvider.php | 53 +++++++++++++++++++ Classes/Domain/Model/Transfer/FilterDto.php | 2 +- .../Domain/Repository/VisitorRepository.php | 23 +++++++- .../Build/JavaScript/Backend/Diagram.js | 2 +- .../Private/Language/de.locallang_db.xlf | 13 +++++ Resources/Private/Language/locallang_db.xlf | 10 ++++ .../Partials/Box/Leads/TimeFrames.html | 26 +++++++++ Resources/Private/Templates/Lead/List.html | 1 + 10 files changed, 133 insertions(+), 7 deletions(-) create mode 100644 Classes/Domain/DataProvider/LeadsPerTimeDataProvider.php create mode 100644 Resources/Private/Partials/Box/Leads/TimeFrames.html diff --git a/Classes/Controller/LeadController.php b/Classes/Controller/LeadController.php index 01bff74e..bf9e8bc7 100644 --- a/Classes/Controller/LeadController.php +++ b/Classes/Controller/LeadController.php @@ -11,6 +11,7 @@ use In2code\Lux\Domain\DataProvider\CompanyCategoryScoringsDataProvider; use In2code\Lux\Domain\DataProvider\CompanyScoringWeeksDataProvider; use In2code\Lux\Domain\DataProvider\IdentificationMethodsDataProvider; +use In2code\Lux\Domain\DataProvider\LeadsPerTimeDataProvider; use In2code\Lux\Domain\DataProvider\PagevisistsDataProvider; use In2code\Lux\Domain\DataProvider\ReferrerAmountDataProvider; use In2code\Lux\Domain\DataProvider\RevenueClassDataProvider; @@ -122,6 +123,7 @@ public function listAction(FilterDto $filter, string $export = ''): ResponseInte $this->view->assignMultiple([ 'numberOfVisitorsData' => GeneralUtility::makeInstance(PagevisistsDataProvider::class, $filter), 'hottestVisitors' => $this->visitorRepository->findByHottestScorings($filter, 8), + 'visitorsPerTimeData' => GeneralUtility::makeInstance(LeadsPerTimeDataProvider::class, $filter), 'filter' => $filter, 'allVisitors' => $this->visitorRepository->findAllWithIdentifiedFirst($filter), 'luxCategories' => $this->categoryRepository->findAllLuxCategories(), diff --git a/Classes/Domain/DataProvider/AbstractDataProvider.php b/Classes/Domain/DataProvider/AbstractDataProvider.php index f25895c0..84f7fb1a 100644 --- a/Classes/Domain/DataProvider/AbstractDataProvider.php +++ b/Classes/Domain/DataProvider/AbstractDataProvider.php @@ -55,11 +55,11 @@ public function getTitlesList(): string public function getAmountsFromData(): array { - $amouts = []; + $amounts = []; if (isset($this->getData()['amounts'])) { - $amouts = $this->getData()['amounts']; + $amounts = $this->getData()['amounts']; } - return (array)$amouts; + return (array)$amounts; } public function getAmountsList(): string @@ -69,7 +69,7 @@ public function getAmountsList(): string public function getAmounts2FromData(): array { - return (array)$this->getData()['amounts2']; + return (array)($this->getData()['amounts2'] ?? []); } public function getAmounts2List(): string diff --git a/Classes/Domain/DataProvider/LeadsPerTimeDataProvider.php b/Classes/Domain/DataProvider/LeadsPerTimeDataProvider.php new file mode 100644 index 00000000..cc8f1c37 --- /dev/null +++ b/Classes/Domain/DataProvider/LeadsPerTimeDataProvider.php @@ -0,0 +1,53 @@ + [ + * 50, + * 88, + * 33 + * ], + * 'titles' => [ + * 'January', + * 'February', + * 'Now' + * ] + * ] + * + * @return void + * @throws Exception + */ + public function prepareData(): void + { + $this->filter->removeShortMode(); + + $visitorRepository = GeneralUtility::makeInstance(VisitorRepository::class); + $intervals = $this->filter->getIntervals(); + $frequency = (string)$intervals['frequency']; + foreach ($intervals['intervals'] as $interval) { + // New visitors + $this->data['amounts'][] = $visitorRepository->findAmountOfNewVisitorsInTimeFrame( + $interval['start'], + $interval['end'] + ); + + // Any visitors + $this->data['amounts2'][] = $visitorRepository->findAmountOfVisitorsInTimeFrame( + $interval['start'], + $interval['end'] + ); + $this->data['titles'][] = $this->getLabelForFrequency($frequency, $interval['start']); + } + $this->overruleLatestTitle($frequency); + } +} diff --git a/Classes/Domain/Model/Transfer/FilterDto.php b/Classes/Domain/Model/Transfer/FilterDto.php index c548f8b7..46bc584d 100644 --- a/Classes/Domain/Model/Transfer/FilterDto.php +++ b/Classes/Domain/Model/Transfer/FilterDto.php @@ -560,7 +560,7 @@ protected function getStartIntervals(): array $start = $this->getStartTimeForFilter(true); $end = $this->getEndTimeForFilter(); $deltaSeconds = $end->getTimestamp() - $start->getTimestamp(); - if ($deltaSeconds <= 86400) { // until 1 days + if ($deltaSeconds <= 86400) { // until 1 day return ['intervals' => $this->getHourIntervals(), 'frequency' => 'hour']; } if ($deltaSeconds <= 1209600) { // until 2 weeks diff --git a/Classes/Domain/Repository/VisitorRepository.php b/Classes/Domain/Repository/VisitorRepository.php index cb266e43..993e0057 100644 --- a/Classes/Domain/Repository/VisitorRepository.php +++ b/Classes/Domain/Repository/VisitorRepository.php @@ -186,7 +186,7 @@ public function findByProperty(string $propertyName, string $propertyValue): ?Vi } /** - * Find a small couple of hottest visitors + * Find a small couple of the hottest visitors * * @param FilterDto $filter * @param int $limit @@ -482,6 +482,27 @@ public function findLatestVisitorsWithIpAddress(int $limit, DateTime $time, bool return $connection->executeQuery($sql)->fetchAllKeyValue(); } + public function findAmountOfVisitorsInTimeFrame(DateTime $start, DateTime $end): int + { + $sql = 'select distinct v.uid 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 pv.crdate >= ' . $start->getTimestamp() . ' and pv.crdate <= ' . $end->getTimestamp() + . ' group by v.uid'; + $connection = DatabaseUtility::getConnectionForTable(Visitor::TABLE_NAME); + $rows = $connection->executeQuery($sql)->fetchAllNumeric(); + return count($rows); + } + + public function findAmountOfNewVisitorsInTimeFrame(DateTime $start, DateTime $end): int + { + $sql = 'select count(uid) from ' . Visitor::TABLE_NAME + . ' where deleted=0 and blacklisted=0' + . ' and crdate >= ' . $start->getTimestamp() . ' and crdate <= ' . $end->getTimestamp(); + $connection = DatabaseUtility::getConnectionForTable(Visitor::TABLE_NAME); + return (int)$connection->executeQuery($sql)->fetchOne(); + } + public function getScoringSumFromCompany(Company $company): int { $connection = DatabaseUtility::getConnectionForTable(Visitor::TABLE_NAME); diff --git a/Resources/Private/Build/JavaScript/Backend/Diagram.js b/Resources/Private/Build/JavaScript/Backend/Diagram.js index 716a1187..9381c28b 100644 --- a/Resources/Private/Build/JavaScript/Backend/Diagram.js +++ b/Resources/Private/Build/JavaScript/Backend/Diagram.js @@ -187,7 +187,7 @@ define(['jquery', 'TYPO3/CMS/Lux/Vendor/Chart.min'], function($) { } }]; - // Use a logarithmic y-axes (normally only if there is more then only one line with a big difference) + // Use a logarithmic y-axes (normally only if there is more than only one line with a big difference) if (element.hasAttribute('data-chart-max-y') && element.hasAttribute('data-chart-max-y') > 0) { yAxes = [{ type: 'logarithmic', diff --git a/Resources/Private/Language/de.locallang_db.xlf b/Resources/Private/Language/de.locallang_db.xlf index 7ee06450..e7e7a09d 100644 --- a/Resources/Private/Language/de.locallang_db.xlf +++ b/Resources/Private/Language/de.locallang_db.xlf @@ -1843,6 +1843,19 @@ Zeige die beisten UTM Media + + Leads per time + Leads pro Zeitraum + + + New leads + Neue Leads + + + Any leads + Alle Leads + + Latest companies on your website Letzte Firmen auf der Website diff --git a/Resources/Private/Language/locallang_db.xlf b/Resources/Private/Language/locallang_db.xlf index 3a38e2ea..a84a376a 100644 --- a/Resources/Private/Language/locallang_db.xlf +++ b/Resources/Private/Language/locallang_db.xlf @@ -1394,6 +1394,16 @@ Show best UTM media + + Leads per time + + + New leads + + + Any leads + + Latest companies on your website diff --git a/Resources/Private/Partials/Box/Leads/TimeFrames.html b/Resources/Private/Partials/Box/Leads/TimeFrames.html new file mode 100644 index 00000000..a85cc576 --- /dev/null +++ b/Resources/Private/Partials/Box/Leads/TimeFrames.html @@ -0,0 +1,26 @@ +
+
+

+ Leads per time +

+
+
+ + +
+ +
+
+ + + +
+
+
diff --git a/Resources/Private/Templates/Lead/List.html b/Resources/Private/Templates/Lead/List.html index 70540ac0..2d457ffb 100644 --- a/Resources/Private/Templates/Lead/List.html +++ b/Resources/Private/Templates/Lead/List.html @@ -35,6 +35,7 @@
+
From f3f6fdee16935b2cdeb212de25a08c8cc683403b Mon Sep 17 00:00:00 2001 From: Alexander Kellner Date: Sat, 19 Aug 2023 16:48:44 +0200 Subject: [PATCH 2/2] [TASK] Release preparations --- Documentation/Technical/Changelog/Index.md | 1 + ext_emconf.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Documentation/Technical/Changelog/Index.md b/Documentation/Technical/Changelog/Index.md index 39f3759f..67f51dfe 100644 --- a/Documentation/Technical/Changelog/Index.md +++ b/Documentation/Technical/Changelog/Index.md @@ -25,6 +25,7 @@ | Version | Date | State | TYPO3 | Description | |------------|------------|----------|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| 33.1.0 | 2023-08-19 | Feature | `11.5 + 12.4` | New diagram in lead list shows number of new or all leads within a timeframe | | 33.0.1 | 2023-08-19 | Bugfix | `11.5 + 12.4` | Fix backend module configuration for TYPO3 12 (to set correct editor permissions) | | 33.0.0 | 2023-08-14 | Feature | `11.5 + 12.4` | Color adjustments of LUX for a better readability, small improvements of readabledate viewhelper, don't show empty values in UTM diagrams | | 32.2.3 | 2023-08-10 | Bugfix | `11.5 + 12.4` | Fix socialmedia diagram in analysis dashboard | diff --git a/ext_emconf.php b/ext_emconf.php index d05b8f01..4b9ef5c8 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -4,7 +4,7 @@ 'description' => 'Living User Experience - LUX - the Marketing Automation tool for TYPO3. Turn your visitors to leads. Identification and profiling of your visitors within your TYPO3 website.', 'category' => 'plugin', - 'version' => '33.0.1', + 'version' => '33.1.0', 'author' => 'Alex Kellner', 'author_email' => 'alexander.kellner@in2code.de', 'author_company' => 'in2code.de',