feat(автоподбор): DI-сборка DeepStudyCollector за тумблером

This commit is contained in:
Дмитрий
2026-07-03 23:43:45 +03:00
parent 8fafbc0ba8
commit 8a7b2ec12d
2 changed files with 33 additions and 2 deletions
@@ -28,6 +28,8 @@ use App\Services\Autopodbor\Agent\LiveFindCompetitors;
use App\Services\Autopodbor\Agent\RealCompetitorAgent;
use App\Services\Autopodbor\Agent\Similarity\AitunnelEmbedder;
use App\Services\Autopodbor\Agent\Similarity\EmbeddingRelevance;
use App\Services\Autopodbor\Agent\Study\DeepStudyCollector;
use App\Services\Autopodbor\Agent\Study\SiteOpener;
use App\Services\Autopodbor\AutopodborDedup;
use App\Services\Autopodbor\AutopodborNormalizer;
use Illuminate\Http\Client\Factory as HttpFactory;
@@ -51,16 +53,24 @@ class AutopodborServiceProvider extends ServiceProvider
concurrency: (int) config('services.xfetch.concurrency', 4),
);
$siteFetcher = new CurlPlaywrightFetcher;
$fetcher = new CompositeFetcher(
siteFetcher: new CurlPlaywrightFetcher,
siteFetcher: $siteFetcher,
directoryFetcher: new XfetchDirectoryFetcher($xfetch),
);
$deep = config('autopodbor.deep_study')
? new DeepStudyCollector(
xfetch: $xfetch,
opener: new SiteOpener($siteFetcher),
)
: null;
$liveFind = config('autopodbor.real_find')
? $this->buildLiveFind($xfetch)
: null;
return new RealCompetitorAgent($fetcher, new FakeCompetitorAgent, liveFind: $liveFind);
return new RealCompetitorAgent($fetcher, new FakeCompetitorAgent, liveFind: $liveFind, deep: $deep);
});
}
@@ -0,0 +1,21 @@
<?php
use App\Services\Autopodbor\Agent\CompetitorAgent;
use App\Services\Autopodbor\Agent\RealCompetitorAgent;
it('deep_study ВКЛ → контейнер отдаёт RealCompetitorAgent с DeepStudyCollector', function () {
config()->set('autopodbor.deep_study', true);
config()->set('services.xfetch.key', 'test');
$agent = app(CompetitorAgent::class);
expect($agent)->toBeInstanceOf(RealCompetitorAgent::class);
$ref = new ReflectionProperty(RealCompetitorAgent::class, 'deep');
expect($ref->getValue($agent))->not->toBeNull();
});
it('deep_study ВЫКЛ → deep равен null', function () {
config()->set('autopodbor.deep_study', false);
config()->set('services.xfetch.key', 'test');
$agent = app(CompetitorAgent::class);
$ref = new ReflectionProperty(RealCompetitorAgent::class, 'deep');
expect($ref->getValue($agent))->toBeNull();
});