Skip to content

Commit

Permalink
fixup! fix(db): also chunk MariaDB deletes
Browse files Browse the repository at this point in the history
  • Loading branch information
miaulalala committed Sep 12, 2023
1 parent e613bbe commit 21b5fe6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 3 additions & 1 deletion lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
use OCP\User\Events\UserDeletedEvent;
use OCP\Util;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;

class Application extends App implements IBootstrap {
public const APP_ID = 'activity';
Expand Down Expand Up @@ -110,7 +111,8 @@ public function register(IRegistrationContext $context): void {
$context->registerService(Data::class, function (ContainerInterface $c) {
return new Data(
$c->get(IManager::class),
$c->get('ActivityConnectionAdapter')
$c->get('ActivityConnectionAdapter'),
$c->get(LoggerInterface::class),
);
});

Expand Down
10 changes: 5 additions & 5 deletions lib/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,8 @@ public function getActivitySince(string $user, int $since, bool $byOthers) {
* @return void
*/
private function deleteActivitiesForMySQL(array $conditions): void {
$query = $this->connection->getQueryBuilder();
$query->select('activity_id')
$subQuery = $this->connection->getQueryBuilder();
$subQuery->select('activity_id')
->from('activity');

foreach ($conditions as $column => $comparison) {
Expand All @@ -492,11 +492,11 @@ private function deleteActivitiesForMySQL(array $conditions): void {
$operation = '=';
$value = $comparison;
}
$query->where($query->expr()->comparison($column, $operation, $query->createNamedParameter($value)));
$subQuery->where($subQuery->expr()->comparison($column, $operation, $subQuery->createNamedParameter($value)));
}

$query->setMaxResults(10000);
$result = $query->executeQuery();
$subQuery->setMaxResults(10000);
$result = $subQuery->executeQuery();
$count = $result->rowCount();
if($count === 0) {
return;
Expand Down

0 comments on commit 21b5fe6

Please sign in to comment.