Commit 7c82ea6a authored by Thomas Löffler's avatar Thomas Löffler

Add new download counts into generated xml file

parent 7f71179c
Pipeline #10079 passed with stages
in 8 minutes
......@@ -56,6 +56,7 @@ class CombinedExtensionRepository
'v.review_state',
'v.em_category',
'v.download_counter',
'v.frontend_download_counter',
'v.file_hash',
'v.upload_date',
'v.upload_comment',
......@@ -72,19 +73,30 @@ class CombinedExtensionRepository
'e',
$queryBuilder->expr()->eq('v.extension', $queryBuilder->quoteIdentifier('e.uid'))
)
->leftJoin(
'v',
'tx_terfe2_domain_model_download',
'd',
$queryBuilder->expr()->eq('v.uid', $queryBuilder->quoteIdentifier('d.version_id'))
)
->where(
$queryBuilder->expr()->eq('e.hidden', 0),
$queryBuilder->expr()->eq('e.deleted', 0),
$queryBuilder->expr()->eq('v.hidden', 0),
$queryBuilder->expr()->eq('v.deleted', 0)
)
->groupBy('v.uid')
->add(
'select',
'COUNT(' . $queryBuilder->quoteIdentifier('d.counter') . ') AS newDownloads',
true
)
->execute();
while ($row = $stmt->fetch()) {
$extensionKey = $row['extensionkey'];
$versionNumber = $row['version'];
$groupedVersionsByExtension[$extensionKey]['frontend_user'] = $row['frontend_user'];
$groupedVersionsByExtension[$extensionKey]['downloads'] = $row['downloads'];
if (empty($row['external_manual'])) {
try {
......@@ -93,6 +105,8 @@ class CombinedExtensionRepository
$row['external_manual'] = '';
}
}
$row['download_counter'] += $row['frontend_download_counter'] + $row['newDownloads'];
$groupedVersionsByExtension[$extensionKey]['downloads'] += $row['download_counter'];
$groupedVersionsByExtension[$extensionKey]['versions'][$versionNumber] = $row;
}
......
......@@ -213,6 +213,7 @@ class VersionUtility
if (null === $downloadInfo) {
$downloadInfo = new Download();
$downloadInfo->setPid(2);
$downloadInfo->setExtensionKey($extensionKey);
$downloadInfo->setSource($source);
$downloadInfo->setMonth($month);
......
......@@ -235,7 +235,7 @@ class ExtensionTest extends \Nimut\TestingFramework\TestCase\UnitTestCase
{
$extension = $this->getAccessibleMock(
Extension::class,
['dummy']
['dummy']
);
$version = new Version();
$version->setDownloadCounter(12345);
......
......@@ -179,7 +179,8 @@ CREATE TABLE `tx_terfe2_domain_model_download` (
KEY extension_key (extension_key),
KEY `source` (source),
KEY `downloadsByMonth` (`extension_key`, `source`, `month`),
KEY `downloadsByMonthAndVersion` (`extension_key`, `source`, `month`, `version_id`)
KEY `downloadsByMonthAndVersion` (`extension_key`, `source`, `month`, `version_id`),
KEY `downloadsByVersion` (`extension_key`, `source`, `version_id`)
);
# ======================================================================
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment