• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Freegle / Iznik / 21695

16 Jun 2026 06:32PM UTC coverage: 70.827%. First build
21695

push

circleci

fnnbrr
Merge remote-tracking branch 'origin/master' into messages-multiple-groups

10985 of 14592 branches covered (75.28%)

Branch coverage included in aggregate %.

7929 of 11826 new or added lines in 242 files covered. (67.05%)

118999 of 168932 relevant lines covered (70.44%)

36.25 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/iznik-batch/app/Console/Commands/Location/UpdatePostcodesCommand.php
1
<?php
2

3
namespace App\Console\Commands\Location;
4

5
use App\Services\DoogalService;
6
use Illuminate\Console\Command;
7

8
/**
9
 * Add new UK postcodes and refresh changed lat/lng from the Doogal Code-Point
10
 * dataset. Faithful migration of V1 scripts/cli/doogal.php and the cron/doogal
11
 * wrapper (which downloaded + unzipped the CSV before running it).
12
 */
13
class UpdatePostcodesCommand extends Command
14
{
15
    protected $signature = 'locations:update-postcodes
16
                            {--file= : Path to an already-extracted Code-Point/Doogal CSV (skips download)}
17
                            {--url= : Override the postcodes.zip download URL}
18
                            {--keep : Keep the downloaded/extracted temp files}';
19

20
    protected $description = 'Add new UK postcodes and refresh changed lat/lng from the Doogal dataset (V1 cli/doogal.php)';
21

NEW
22
    public function handle(DoogalService $service): int
×
23
    {
NEW
24
        $file = $this->option('file');
×
NEW
25
        $downloaded = false;
×
26

NEW
27
        if (!$file) {
×
NEW
28
            $this->info('Downloading postcode dataset...');
×
29
            try {
NEW
30
                $file = $service->fetchCsv($this->option('url'));
×
NEW
31
                $downloaded = true;
×
NEW
32
            } catch (\Throwable $e) {
×
NEW
33
                $this->error('Download failed: '.$e->getMessage());
×
34

NEW
35
                return self::FAILURE;
×
36
            }
37
        }
38

NEW
39
        if (!is_file($file)) {
×
NEW
40
            $this->error("CSV file not found: {$file}");
×
41

NEW
42
            return self::FAILURE;
×
43
        }
44

NEW
45
        $this->info("Processing postcodes from: {$file}");
×
46

47
        try {
NEW
48
            $result = $service->process($file, function (int $processed, int $added, int $updated) {
×
NEW
49
                $this->line("  ...{$processed} processed ({$added} added, {$updated} updated)");
×
NEW
50
            });
×
NEW
51
        } catch (\Throwable $e) {
×
NEW
52
            $this->error($e->getMessage());
×
53

NEW
54
            return self::FAILURE;
×
55
        } finally {
NEW
56
            if ($downloaded && !$this->option('keep')) {
×
NEW
57
                @unlink($file);
×
NEW
58
                @rmdir(dirname($file));
×
59
            }
60
        }
61

NEW
62
        $this->info(
×
NEW
63
            "Done. Processed {$result['processed']}, added {$result['added']}, "
×
NEW
64
            ."updated {$result['updated']}, failed {$result['failed']}."
×
NEW
65
        );
×
66

NEW
67
        return self::SUCCESS;
×
68
    }
69
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc