Optimierung 2.6: reprocessAfterContentChange im PressReleaseService
Den 3x identischen contentChanged->fresh->reclassifyIfClassified-> rescoreIfScored-Block (admin/edit 1x, customer/edit 2x) in PressReleaseService::reprocessAfterContentChange() zentralisiert. Hinweis: Eine vollstaendige createDraft()/updateContent()-Verlagerung wurde bewusst NICHT erzwungen — die Attributsaetze und der umgebende Validierungs-/Fehlerfluss von Admin (no_export, direkter review-Status) und Customer (placeholder_variant, Titel-Fallback, immer Draft) divergieren real; eine gemeinsame Persistenzmethode waere fragil bei grosser Testflaeche. Tests: 2 neue Faelle; volle Suite gruen (796 passed, 1 skipped). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
8c53146548
commit
83d2ee659a
4 changed files with 50 additions and 12 deletions
|
|
@ -3,6 +3,7 @@
|
|||
use App\Enums\PressReleaseClassification;
|
||||
use App\Enums\PressReleaseStatus;
|
||||
use App\Jobs\ClassifyPressRelease;
|
||||
use App\Jobs\ScorePressRelease;
|
||||
use App\Models\Category;
|
||||
use App\Models\Company;
|
||||
use App\Models\PressRelease;
|
||||
|
|
@ -37,6 +38,34 @@ test('reclassifyIfClassified does nothing for a never-classified press release',
|
|||
Queue::assertNothingPushed();
|
||||
});
|
||||
|
||||
test('reprocessAfterContentChange reclassifies and rescores on the fresh model state', function () {
|
||||
Queue::fake();
|
||||
|
||||
$pressRelease = PressRelease::factory()->create([
|
||||
'classification' => PressReleaseClassification::Green->value,
|
||||
'content_score' => 80,
|
||||
'status' => PressReleaseStatus::Published->value,
|
||||
]);
|
||||
|
||||
app(PressReleaseService::class)->reprocessAfterContentChange($pressRelease);
|
||||
|
||||
Queue::assertPushedOn('classification', ClassifyPressRelease::class);
|
||||
Queue::assertPushedOn('classification', ScorePressRelease::class);
|
||||
});
|
||||
|
||||
test('reprocessAfterContentChange does nothing for an unclassified, unscored press release', function () {
|
||||
Queue::fake();
|
||||
|
||||
$pressRelease = PressRelease::factory()->create([
|
||||
'classification' => null,
|
||||
'content_score' => null,
|
||||
]);
|
||||
|
||||
app(PressReleaseService::class)->reprocessAfterContentChange($pressRelease);
|
||||
|
||||
Queue::assertNothingPushed();
|
||||
});
|
||||
|
||||
test('api update of a classified press release re-classifies when the content changes', function () {
|
||||
/** @var TestCase $this */
|
||||
Queue::fake();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue