Skip to content

Commit

Permalink
fixup! fixup! fixup! fixup! fix: Delete inactive sessions in one query
Browse files Browse the repository at this point in the history
  • Loading branch information
juliushaertl committed Jun 21, 2023
1 parent e4d4c3c commit f41f4e8
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions tests/unit/Db/SessionMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ public function testDeleteInactiveWithoutStepsKeep() {
self::assertCount(0, $this->sessionMapper->findAll(2));
}

public function testDeleteInactiveWithoutSteps1010() {
public function testDeleteInactiveWithoutStepsMultiple() {
$this->sessionMapper->deleteByDocumentId(1);

\OC::$server->getDatabaseConnection()->beginTransaction();
for ($i = 0;$i < 1010;$i++) {
$count = 10;
for ($i = 0;$i < $count;$i++) {
$this->sessionMapper->insert(Session::fromParams([
'userId' => 'admin',
'documentId' => 1,
Expand All @@ -90,15 +90,11 @@ public function testDeleteInactiveWithoutSteps1010() {
'color' => '00ff00',
]));
}
\OC::$server->getDatabaseConnection()->commit();

self::assertCount(1010, $this->sessionMapper->findAll(1));
self::assertCount($count, $this->sessionMapper->findAll(1));

sleep(1);

\OC::$server->getDatabaseConnection()->beginTransaction();
$this->sessionMapper->deleteInactiveWithoutSteps(1);
\OC::$server->getDatabaseConnection()->commit();
$deleted = $this->sessionMapper->deleteInactiveWithoutSteps();
self::assertEquals($count, $deleted);

self::assertCount(0, $this->sessionMapper->findAll(1));
}
Expand Down

0 comments on commit f41f4e8

Please sign in to comment.