diff --git a/config/packages/contributte.monolog.neon b/config/packages/contributte.monolog.neon index 0cff3310..09c4266b 100644 --- a/config/packages/contributte.monolog.neon +++ b/config/packages/contributte.monolog.neon @@ -7,6 +7,7 @@ services: type: Sentry\Client factory: Sentry\ClientBuilder::create([ dsn: ::env(SENTRY_DSN) + max_request_body_size: always ])::getClient() sentry_hub: diff --git a/src/Api/Crawler/ReceiveResultController.php b/src/Api/Crawler/ReceiveResultController.php index a40c522d..6b3a7400 100644 --- a/src/Api/Crawler/ReceiveResultController.php +++ b/src/Api/Crawler/ReceiveResultController.php @@ -77,13 +77,21 @@ public function receiveResult(ApiRequest $request, ApiResponse $response): ApiRe } } - $this->cookieSuggestionsStore->storeCrawledCookies( - $scenarioResponseBody->name, - $scenarioResponseBody->flags['projectId'], - $acceptedCategories, - $scenarioResponseBody->finishedAt ?? new DateTimeImmutable('now'), - $scenarioResponseBody->results->cookies, - ); + try { + $this->cookieSuggestionsStore->storeCrawledCookies( + $scenarioResponseBody->name, + $scenarioResponseBody->flags['projectId'], + $acceptedCategories, + $scenarioResponseBody->finishedAt ?? new DateTimeImmutable('now'), + $scenarioResponseBody->results->cookies, + ); + } catch (Throwable $e) { + $error = new ClientErrorException('Unable to process received crawler result: ' . $e->getMessage(), ApiResponse::S400_BAD_REQUEST, $e); + + $this->logger->error((string) $error); + + throw $error; + } return $response->withStatus(ApiResponse::S200_OK) ->writeJsonBody([ diff --git a/src/Application/CookieSuggestion/CookieSuggestionsStore.php b/src/Application/CookieSuggestion/CookieSuggestionsStore.php index a1a36dcd..92c2ee4e 100644 --- a/src/Application/CookieSuggestion/CookieSuggestionsStore.php +++ b/src/Application/CookieSuggestion/CookieSuggestionsStore.php @@ -35,11 +35,13 @@ use App\ReadModel\CookieSuggestion\CookieSuggestionForResolving; use App\ReadModel\CookieSuggestion\FindCookieSuggestionsForResolvingQuery; use App\ReadModel\CookieSuggestion\GetCookieSuggestionByProjectIdAndNameAndDomainQuery; +use App\ReadModel\Project\GetProjectByIdQuery; use Closure; use DateTimeImmutable; use DateTimeInterface; use DateTimeZone; use Exception; +use InvalidArgumentException; use Psr\Log\LoggerInterface; use SixtyEightPublishers\ArchitectureBundle\Bus\CommandBusInterface; use SixtyEightPublishers\ArchitectureBundle\Bus\QueryBusInterface; @@ -64,6 +66,15 @@ public function __construct( */ public function storeCrawledCookies(string $scenarioName, string $projectId, array $acceptedCategories, DateTimeImmutable $finishedAt, array $cookies): void { + $projectView = $this->queryBus->dispatch(GetProjectByIdQuery::create($projectId)); + + if (null === $projectView) { + throw new InvalidArgumentException(sprintf( + 'The project with ID %s not found.', + $projectId, + )); + } + $cookiesData = null; $getCookiesData = function () use (&$cookiesData, $projectId): array { if (null !== $cookiesData) { diff --git a/src/Infrastructure/Cookie/Doctrine/ReadModel/FindCookieDataForSuggestionQueryHandler.php b/src/Infrastructure/Cookie/Doctrine/ReadModel/FindCookieDataForSuggestionQueryHandler.php index 5dc761b8..37d94d6c 100644 --- a/src/Infrastructure/Cookie/Doctrine/ReadModel/FindCookieDataForSuggestionQueryHandler.php +++ b/src/Infrastructure/Cookie/Doctrine/ReadModel/FindCookieDataForSuggestionQueryHandler.php @@ -34,7 +34,7 @@ public function __invoke(FindCookieDataForSuggestionQuery $query): array ->from('cookie', 'c') ->join('c', 'category', 'cat', 'c.category_id = cat.id AND cat.deleted_at IS NULL') ->join('c', 'cookie_provider', 'cp', 'c.cookie_provider_id = cp.id AND cp.deleted_at IS NULL') - ->leftJoin('c', 'project', 'p', 'p.id = :projectId AND p.deleted_at IS NULL') + ->join('c', 'project', 'p', 'p.id = :projectId AND p.deleted_at IS NULL') ->leftJoin('cp', 'project_has_cookie_provider', 'p_has_cp', 'p_has_cp.cookie_provider_id = cp.id AND p_has_cp.project_id = p.id') ->where('c.deleted_at IS NULL') ->andWhere('cp.private = false OR cp.id = p.cookie_provider_id') diff --git a/src/Web/AdminModule/CookieModule/Presenter/templates/FoundCookies.default.latte b/src/Web/AdminModule/CookieModule/Presenter/templates/FoundCookies.default.latte index 66bd3db6..ae97d12f 100644 --- a/src/Web/AdminModule/CookieModule/Presenter/templates/FoundCookies.default.latte +++ b/src/Web/AdminModule/CookieModule/Presenter/templates/FoundCookies.default.latte @@ -4,7 +4,6 @@ {block #heading_actions} - {svg common/queue-list.svg, class: 'h-4 w-4 mr-2'} {_running_scenarios} @@ -55,7 +54,7 @@ -
+
{foreach $missingCookieSuggestions as $suggestion}
@@ -90,7 +89,7 @@
-
+
{foreach $problematicCookieSuggestions as $suggestion} {include #problematic-cookie-suggestion, suggestion: $suggestion} @@ -119,7 +118,7 @@
-
+
{foreach $unproblematicCookieSuggestions as $suggestion} {include #unproblematic-cookie-suggestion, suggestion: $suggestion} @@ -148,7 +147,7 @@
-
+
{foreach $ignoredCookieSuggestions as $suggestion} {var $originalSuggestion = $suggestion->getOriginalSuggestion()} diff --git a/src/Web/AdminModule/CrawlerModule/Control/ScenarioDetail/templates/scenarioDetailModalControl.latte b/src/Web/AdminModule/CrawlerModule/Control/ScenarioDetail/templates/scenarioDetailModalControl.latte index 1b873aad..2133955b 100644 --- a/src/Web/AdminModule/CrawlerModule/Control/ScenarioDetail/templates/scenarioDetailModalControl.latte +++ b/src/Web/AdminModule/CrawlerModule/Control/ScenarioDetail/templates/scenarioDetailModalControl.latte @@ -27,7 +27,8 @@ {/block} {block #footer} - + + {svg common/queue-list.svg, class: 'h-4 w-4 mr-2'} {_manage_suggestions} diff --git a/src/Web/AdminModule/CrawlerModule/Control/ScenarioList/templates/datagrid.latte b/src/Web/AdminModule/CrawlerModule/Control/ScenarioList/templates/datagrid.latte index b3e57a32..c7cd4ef4 100644 --- a/src/Web/AdminModule/CrawlerModule/Control/ScenarioList/templates/datagrid.latte +++ b/src/Web/AdminModule/CrawlerModule/Control/ScenarioList/templates/datagrid.latte @@ -55,6 +55,6 @@ {define col-duration} {App\Application\Helper\DurationFormatter::formatDiff( $item->createdAt->setTimezone(App\Application\Localization\ApplicationDateTimeZone::get()), - ($item->finishedAt ?? new \DateTimeImmutable('now'))->setTimezone(App\Application\Localization\ApplicationDateTimeZone::get()) + ($item->finishedAt ?? new \DateTimeImmutable('now', new DateTimeZone('UTC')))->setTimezone(App\Application\Localization\ApplicationDateTimeZone::get()) )} {/define} diff --git a/tests/Application/CookieSuggestion/CookieSuggestionStoreTest.php b/tests/Application/CookieSuggestion/CookieSuggestionStoreTest.php index 6eba533e..005929ff 100644 --- a/tests/Application/CookieSuggestion/CookieSuggestionStoreTest.php +++ b/tests/Application/CookieSuggestion/CookieSuggestionStoreTest.php @@ -35,6 +35,8 @@ use App\ReadModel\CookieSuggestion\CookieSuggestionForResolving; use App\ReadModel\CookieSuggestion\FindCookieSuggestionsForResolvingQuery; use App\ReadModel\CookieSuggestion\GetCookieSuggestionByProjectIdAndNameAndDomainQuery; +use App\ReadModel\Project\GetProjectByIdQuery; +use App\ReadModel\Project\ProjectView; use Closure; use DateTimeImmutable; use DateTimeInterface; @@ -43,6 +45,7 @@ use Mockery; use SixtyEightPublishers\ArchitectureBundle\Bus\CommandBusInterface; use SixtyEightPublishers\ArchitectureBundle\Bus\QueryBusInterface; +use SixtyEightPublishers\ArchitectureBundle\ReadModel\View\ArrayViewData; use SixtyEightPublishers\CrawlerClient\Controller\Scenario\ValueObject\Cookie as CrawlerClientCookie; use Tester\Assert; use Tester\TestCase; @@ -63,6 +66,10 @@ public function testCrawledCookieStoring(): void $finishedAtString = $finishedAt->format(DateTimeInterface::ATOM); $store = $this->createStore( [ + [ + GetProjectByIdQuery::create($projectId), + ProjectView::fromData(new ArrayViewData([])), + ], [ FindCookieDataForSuggestionQuery::create($projectId), [ diff --git a/translations/App_Web_AdminModule_CookieModule_Control_ProviderList_ProviderListControl.cs.neon b/translations/App_Web_AdminModule_CookieModule_Control_ProviderList_ProviderListControl.cs.neon index a21080a5..917be81d 100644 --- a/translations/App_Web_AdminModule_CookieModule_Control_ProviderList_ProviderListControl.cs.neon +++ b/translations/App_Web_AdminModule_CookieModule_Control_ProviderList_ProviderListControl.cs.neon @@ -1,8 +1,8 @@ name: Název code: Kód active: Aktivní -private: Privátní -private_description: 'Privátní poskytovatel je "hlavní" poskytovatel vázaný na daný projekt.' +private: Projektový +private_description: 'Projektový poskytovatel je "hlavní" poskytovatel vázaný na daný projekt.' type: Typ link: Odkaz number_of_cookies: Cookies diff --git a/translations/App_Web_AdminModule_CookieModule_Control_ProviderList_ProviderListControl.en.neon b/translations/App_Web_AdminModule_CookieModule_Control_ProviderList_ProviderListControl.en.neon index b3080af7..02fd39a8 100644 --- a/translations/App_Web_AdminModule_CookieModule_Control_ProviderList_ProviderListControl.en.neon +++ b/translations/App_Web_AdminModule_CookieModule_Control_ProviderList_ProviderListControl.en.neon @@ -1,8 +1,8 @@ name: Name code: Code active: Active -private: Private -private_description: 'A private provider is the "main" provider associated with the project.' +private: Project provider +private_description: 'A project provider is the "main" provider associated with the project.' type: Type link: Link number_of_cookies: Cookies