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

Freegle / Iznik / 4927

18 Apr 2026 09:53AM UTC coverage: 71.536% (+0.3%) from 71.267%
4927

push

circleci

edwh
fix(message): generate synthetic messageid on PUT /message (V1 parity)

V1 Message.php:2708 invents a unique messageid when none is supplied,
with a -{groupid} suffix at line 2717. V2 was omitting the column from
the INSERT, leaving messages.messageid NULL and breaking downstream
dedupe and cross-reference joins that assume it's populated.

Uses a new utils.USER_DOMAIN constant ("users.ilovefreegle.org") which
also replaces the hardcoded literal in OurDomain().

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

13363 of 20382 branches covered (65.56%)

Branch coverage included in aggregate %.

9 of 9 new or added lines in 2 files covered. (100.0%)

570 existing lines in 21 files now uncovered.

95747 of 132142 relevant lines covered (72.46%)

21.61 hits per line

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

89.29
/iznik-batch/app/Console/Commands/Message/GenerateEmbeddingsCommand.php
1
<?php
2

3
namespace App\Console\Commands\Message;
4

5
use App\Services\EmbeddingService;
6
use App\Traits\GracefulShutdown;
7
use Illuminate\Console\Command;
8
use Illuminate\Support\Facades\DB;
9
use Illuminate\Support\Facades\Log;
10

11
/**
12
 * Nightly embedding generator — embeds messages that don't yet have a row
13
 * in messages_embeddings. See RegenerateEmbeddingsCommand for the full
14
 * rebuild used after recipe or model changes.
15
 */
16
class GenerateEmbeddingsCommand extends Command
17
{
18
    use GracefulShutdown;
19

20
    protected $signature = 'embeddings:generate
21
                            {--backfill : Process all messages without embeddings}
22
                            {--limit=500 : Maximum messages to process per run}
23
                            {--chunk=100 : Messages per embedder invocation}';
24

25
    protected $description = 'Generate vector embeddings for live messages missing from messages_embeddings';
26

27
    public function handle(EmbeddingService $service): int
4✔
28
    {
29
        $this->registerShutdownHandlers();
4✔
30

31
        $limit = (int) $this->option('limit');
4✔
32
        $chunkSize = max(1, (int) $this->option('chunk'));
4✔
33

34
        if ($this->option('backfill')) {
4✔
35
            $limit = 50000;
1✔
36
        }
37

38
        $totalCount = 0;
4✔
39
        $remaining = $limit;
4✔
40

41
        while ($remaining > 0) {
4✔
42
            if ($this->shouldAbort()) {
4✔
UNCOV
43
                $this->warn('Aborting due to shutdown signal.');
×
UNCOV
44
                break;
×
45
            }
46

47
            $batchLimit = min($remaining, $chunkSize);
4✔
48

49
            $messages = DB::select('
4✔
50
                SELECT ms.msgid, m.subject, LEFT(m.textbody, 500) as body
51
                FROM messages_spatial ms
52
                JOIN messages m ON m.id = ms.msgid
53
                LEFT JOIN messages_embeddings me ON me.msgid = ms.msgid
54
                WHERE me.msgid IS NULL
55
                  AND ms.successful = 0
56
                  AND ms.promised = 0
57
                ORDER BY ms.arrival DESC
58
                LIMIT ?
59
            ', [$batchLimit]);
4✔
60

61
            if (empty($messages)) {
4✔
62
                break;
4✔
63
            }
64

65
            $this->info(sprintf('Processing chunk of %d messages (%d done so far)...', count($messages), $totalCount));
1✔
66

67
            $count = $service->processMessages($messages);
1✔
68
            if ($count === false) {
1✔
UNCOV
69
                return Command::FAILURE;
×
70
            }
71

72
            $totalCount += $count;
1✔
73
            $remaining -= count($messages);
1✔
74
        }
75

76
        if ($totalCount === 0) {
4✔
77
            $this->info('No messages need embedding.');
3✔
78
        } else {
79
            $this->info("Generated {$totalCount} embeddings.");
1✔
80
            Log::info('Embedding generation complete', ['count' => $totalCount]);
1✔
81
        }
82

83
        return Command::SUCCESS;
4✔
84
    }
85
}
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