-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use log tables to decide which tables can be purged #10304
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
namespace Piwik; | ||
|
||
use Piwik\DataAccess\RawLogDao; | ||
use Piwik\Plugin\LogTablesProvider; | ||
|
||
/** | ||
* Service that deletes log entries. Methods in this class cascade, so deleting visits will delete visit actions, | ||
|
@@ -21,9 +22,15 @@ class LogDeleter | |
*/ | ||
private $rawLogDao; | ||
|
||
public function __construct(RawLogDao $rawLogDao) | ||
/** | ||
* @var LogTablesProvider | ||
*/ | ||
private $logTablesProvider; | ||
|
||
public function __construct(RawLogDao $rawLogDao, LogTablesProvider $logTablesProvider) | ||
{ | ||
$this->rawLogDao = $rawLogDao; | ||
$this->logTablesProvider = $logTablesProvider; | ||
} | ||
|
||
/** | ||
|
@@ -35,33 +42,18 @@ public function __construct(RawLogDao $rawLogDao) | |
*/ | ||
public function deleteVisits($visitIds) | ||
{ | ||
$this->deleteConversions($visitIds); | ||
$this->rawLogDao->deleteVisitActionsForVisits($visitIds); | ||
|
||
return $this->rawLogDao->deleteVisits($visitIds); | ||
} | ||
$numDeletedVisits = 0; | ||
|
||
/** | ||
* Deletes conversions by visit ID. This method cascades, so conversion items are also deleted. | ||
* | ||
* @param int[] $visitIds The list of visits to delete conversions for. | ||
* @return int The number rows deleted. | ||
*/ | ||
public function deleteConversions($visitIds) | ||
{ | ||
$this->deleteConversionItems($visitIds); | ||
return $this->rawLogDao->deleteConversions($visitIds); | ||
} | ||
foreach ($this->logTablesProvider->getAllLogTables() as $logTable) { | ||
if ($logTable->getColumnToJoinOnIdVisit()) { | ||
$numVisits = $this->rawLogDao->deleteFromLogTable($logTable->getName(), $visitIds); | ||
if ($logTable->getName() === 'log_visit') { | ||
$numDeletedVisits = $numVisits; | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Deletes conversion items by visit ID. | ||
* | ||
* @param int[] $visitIds The list of visits to delete conversions for. | ||
* @return int The number rows deleted. | ||
*/ | ||
public function deleteConversionItems($visitIds) | ||
{ | ||
return $this->rawLogDao->deleteConversionItems($visitIds); | ||
return $numDeletedVisits; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. before we returned only the number of visits deleted in log_visit but now we return the sum of deleted visits. I had a look and the value returned here seems to be actually not used (not even in the output of the console command anymore) so it shouldn't change anything but only "be more accurate" to return the sum of deleted entries |
||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was all duplicated code