diff --git a/app/Models/Recording.php b/app/Models/Recording.php index 6262cf2..1d514de 100644 --- a/app/Models/Recording.php +++ b/app/Models/Recording.php @@ -434,7 +434,7 @@ class Recording extends Model $startedAt = $this->transcription_started_at; $durationSeconds = $startedAt === null ? null - : max(0, (int) round($startedAt->diffInSeconds($finishedAt))); + : max(0, $finishedAt->getTimestamp() - $startedAt->getTimestamp()); $this->forceFill([ 'transcript' => $text, diff --git a/tests/Feature/RecordingUploadTest.php b/tests/Feature/RecordingUploadTest.php index a0b17ed..1831ced 100644 --- a/tests/Feature/RecordingUploadTest.php +++ b/tests/Feature/RecordingUploadTest.php @@ -210,7 +210,7 @@ class RecordingUploadTest extends TestCase Transcription::fake(['Hello from the recorder.']); - $this->freezeTime(); + $this->travelTo(now()->startOfSecond()); $recording = Recording::query()->create([ 'user_id' => $this->user->id, @@ -231,6 +231,10 @@ class RecordingUploadTest extends TestCase $this->assertSame(100, $recording->transcription_percent); $this->assertSame('Transcription complete', $recording->transcription_progress); $this->assertNotNull($recording->transcribed_at); + $this->assertSame( + $recording->transcribed_at->getTimestamp() - $recording->transcription_started_at->getTimestamp(), + $recording->transcription_duration_seconds, + ); $this->assertSame(42, $recording->transcription_duration_seconds); $this->assertSame('42s', $recording->transcriptionStatusPayload()['transcription_duration_human']); }