Skip to content
This repository was archived by the owner on Jun 3, 2026. It is now read-only.

Commit 7a5736b

Browse files
committed
Add fix command to fix pressures in samples
- Add a command to call fix sample pressures service - Add service to fix pressure in samples of a dive - Add save method to DiveSampleRepository - Introduce a visitor pattern on the samples to iterate through the samples and mutate them on an access basis. - Add tests for all the above. Other improvements - Update husky to v8
1 parent caa1ce6 commit 7a5736b

27 files changed

Lines changed: 591 additions & 355 deletions

‎.husky/pre-commit‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npx lint-staged
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Console\Commands;
6+
7+
use App\Domain\DiveSamples\Services\FixDiveSamplePressures;
8+
use App\Models\Dive;
9+
use Illuminate\Console\Command;
10+
use Illuminate\Support\Facades\DB;
11+
12+
final class FixSamplePressures extends Command
13+
{
14+
protected $signature = 'fix:samples:pressures';
15+
16+
protected $description = 'Fixes sample pressures to ensure every pressure sample has only sample for the same tank';
17+
18+
public function handle(FixDiveSamplePressures $fixDiveSamplePressures): int
19+
{
20+
DB::connection()->disableQueryLog();
21+
22+
$dives = Dive::query()->select(['id', 'samples'])->whereNotNull('samples')->cursor();
23+
24+
/** @var Dive $dive */
25+
foreach ($dives as $dive) {
26+
$result = $fixDiveSamplePressures->fix($dive->diveSamples());
27+
28+
if ($result->touched) {
29+
$this->output->info('Updated dive ' . $dive->id);
30+
} else {
31+
$this->output->info('Skipped dive ' . $dive->id);
32+
}
33+
}
34+
return 0;
35+
}
36+
}

‎app/Console/Commands/ImportDataNodeJS.php‎

Lines changed: 0 additions & 288 deletions
This file was deleted.

app/Domain/Dives/Repositories/DiveSamplesRepository.php renamed to app/Domain/DiveSamples/DiveSamplesRepository.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
declare(strict_types=1);
44

5-
namespace App\Domain\Dives\Repositories;
5+
namespace App\Domain\DiveSamples;
66

7-
use App\Domain\Dives\Entities\DiveSamples;
87
use App\Domain\Dives\ValueObjects\DiveId;
8+
use App\Domain\DiveSamples\Entities\DiveSamples;
99

1010
interface DiveSamplesRepository
1111
{

0 commit comments

Comments
 (0)