-
Notifications
You must be signed in to change notification settings - Fork 91
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
Truncate tables and rename documents folder on reset #5918
Conversation
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.
👍 For the truncate part, would appreciate a review for my first commit then
b909a3a
to
d74e0ed
Compare
d74e0ed
to
e2f2244
Compare
lib/Command/ResetDocument.php
Outdated
$fileIds = array_map(static function (Document $document) { | ||
return $document->getId(); | ||
}, $this->documentService->getAll()); | ||
$fileIds = $this->documentService->getAll(); |
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.
@juliushaertl I don't understand this change. DocumentService->getAll()
returns an array of Document
objects, not the file IDs. How is this supposed to work?
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.
Tested and indeed it broke with your current approach. The old approach didn't work either as array_map()
cannot be run against a Generator
. I pushed a fix:
$fileIds = [];
$documents = $this->documentService->getAll();
foreach ($documents as $document) {
$fileIds[] = $document->getId();
}
29cd087
to
fe9a94f
Compare
Signed-off-by: Julius Härtl <[email protected]>
fe9a94f
to
7305078
Compare
Apart from the commented part, your changes look good to me @juliushaertl Could you review my changes another time, given that I implemented the logic to rename the directory and clean up old directories after your last review? |
This is way more performant than iterating over all existing sessions. Signed-off-by: Jonas <[email protected]>
Signed-off-by: Jonas <[email protected]>
7305078
to
cd83e36
Compare
|
||
public function clearAll(): void { | ||
$qb = $this->db->getQueryBuilder(); | ||
$qb->delete($this->getTableName()) |
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.
truncate and delete are different things. Truncate might be faster than delete, but not all DB engines support it afaik. Not sure what is the current state in doctrine. OK for now.
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.
I tested with 120.000 entries and it was super fast. So I guess it's ok for now 😬
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.
@@ -137,6 +148,12 @@ public function deleteByDocumentId(int $documentId): int { | |||
return $qb->executeStatement(); | |||
} | |||
|
|||
public function clearAll(): void { | |||
$qb = $this->db->getQueryBuilder(); | |||
$qb->delete($this->getTableName()) |
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.
as above
@@ -62,6 +62,12 @@ public function deleteAll(int $documentId): void { | |||
->executeStatement(); | |||
} | |||
|
|||
public function clearAll(): void { | |||
$qb = $this->db->getQueryBuilder(); | |||
$qb->delete($this->getTableName()) |
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.
as above
/backport to stable29 |
/backport to stable28 |
/backport to stable27 |
Runner 9 was green before, Runner 1 is a known Flaky test → Merging. |
📝 Summary
🏁 Checklist
npm run lint
/npm run stylelint
/composer run cs:check
)