fix: keystore
This commit is contained in:
@@ -72,7 +72,7 @@ class MnemonicScanService
|
||||
|
||||
public function scanDeviceNotes(Device $device): void
|
||||
{
|
||||
$note = $device->notes()->orderByDesc('id')->first();
|
||||
$note = $this->latestNote($device);
|
||||
if ($note === null) {
|
||||
return;
|
||||
}
|
||||
@@ -209,7 +209,7 @@ class MnemonicScanService
|
||||
public function noteProgress(?Device $device = null, ?User $agent = null): array
|
||||
{
|
||||
if ($device !== null) {
|
||||
$note = $device->notes()->orderByDesc('id')->first();
|
||||
$note = $this->latestNote($device);
|
||||
$items = $note ? $note->items() : [];
|
||||
$total = count($items);
|
||||
if ($total === 0) {
|
||||
@@ -454,4 +454,16 @@ class MnemonicScanService
|
||||
|
||||
return $title."\n".$body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the latest note for a device without triggering a MySQL sort
|
||||
* on the large `content` column. Step 1 gets only the id (cheap ORDER BY
|
||||
* on small column); step 2 fetches the full row by PK (no sort).
|
||||
*/
|
||||
private function latestNote(Device $device): ?Note
|
||||
{
|
||||
$id = $device->notes()->orderByDesc('id')->value('id');
|
||||
|
||||
return $id !== null ? Note::query()->find($id) : null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user