From 491ecb9086b8d1041e07179468e6e37101664c75 Mon Sep 17 00:00:00 2001 From: Oleh Okhremchuk Date: Tue, 20 Mar 2018 19:34:00 +0200 Subject: [PATCH 01/25] init --- .../Report/Business/Model/ProcessResult.php | 47 +++++++++++++++++ .../Business/Model/ProcessResultInterface.php | 15 ++++++ .../Report/Business/ReportBusinessFactory.php | 30 +++++++++++ .../Zed/Report/Business/ReportFacade.php | 24 +++++++++ .../Report/Business/ReportFacadeInterface.php | 15 ++++++ .../Hook/ReportPostProcessorHookPlugin.php | 24 +++++++++ .../Mapper/ProcessResultMapper.php | 45 +++++++++++++++++ .../Propel/Schema/spy_report.schema.xml | 36 +++++++++++++ .../Persistence/ReportEntityManager.php | 50 +++++++++++++++++++ .../ReportEntityManagerInterface.php | 24 +++++++++ .../Persistence/ReportPersistenceFactory.php | 32 ++++++++++++ .../Report/Persistence/ReportRepository.php | 12 +++++ .../Persistence/ReportRepositoryInterface.php | 7 +++ 13 files changed, 361 insertions(+) create mode 100644 src/SprykerMiddleware/Zed/Report/Business/Model/ProcessResult.php create mode 100644 src/SprykerMiddleware/Zed/Report/Business/Model/ProcessResultInterface.php create mode 100644 src/SprykerMiddleware/Zed/Report/Business/ReportBusinessFactory.php create mode 100644 src/SprykerMiddleware/Zed/Report/Business/ReportFacade.php create mode 100644 src/SprykerMiddleware/Zed/Report/Business/ReportFacadeInterface.php create mode 100644 src/SprykerMiddleware/Zed/Report/Communication/Plugin/Hook/ReportPostProcessorHookPlugin.php create mode 100644 src/SprykerMiddleware/Zed/Report/Persistence/Mapper/ProcessResultMapper.php create mode 100644 src/SprykerMiddleware/Zed/Report/Persistence/Propel/Schema/spy_report.schema.xml create mode 100644 src/SprykerMiddleware/Zed/Report/Persistence/ReportEntityManager.php create mode 100644 src/SprykerMiddleware/Zed/Report/Persistence/ReportEntityManagerInterface.php create mode 100644 src/SprykerMiddleware/Zed/Report/Persistence/ReportPersistenceFactory.php create mode 100644 src/SprykerMiddleware/Zed/Report/Persistence/ReportRepository.php create mode 100644 src/SprykerMiddleware/Zed/Report/Persistence/ReportRepositoryInterface.php diff --git a/src/SprykerMiddleware/Zed/Report/Business/Model/ProcessResult.php b/src/SprykerMiddleware/Zed/Report/Business/Model/ProcessResult.php new file mode 100644 index 0000000..3f5f7e3 --- /dev/null +++ b/src/SprykerMiddleware/Zed/Report/Business/Model/ProcessResult.php @@ -0,0 +1,47 @@ +reportRepository = $reportRepository; + $this->reportEntityManager = $reportEntityManager; + } + + /** + * @param \Generated\Shared\Transfer\ProcessResultTransfer $processResultTransfer + * + * @return \Generated\Shared\Transfer\ProcessResultTransfer + */ + public function saveProcessResult(ProcessResultTransfer $processResultTransfer) + { + $spyProcessEntityTransfer = new SpyProcessEntityTransfer(); + $spyProcessEntityTransfer->setProcessName($processResultTransfer->getProcessName()); + $spyProcessEntityTransfer = $this->reportEntityManager->saveProcess($spyProcessEntityTransfer); + + return $this->reportEntityManager->saveProcessResult($processResultTransfer, $spyProcessEntityTransfer); + } +} diff --git a/src/SprykerMiddleware/Zed/Report/Business/Model/ProcessResultInterface.php b/src/SprykerMiddleware/Zed/Report/Business/Model/ProcessResultInterface.php new file mode 100644 index 0000000..ad10ff0 --- /dev/null +++ b/src/SprykerMiddleware/Zed/Report/Business/Model/ProcessResultInterface.php @@ -0,0 +1,15 @@ +getRepository(), + $this->getEntityManager() + ); + } + + /** + * @return \SprykerMiddleware\Zed\Report\Persistence\Mapper\ProcessResultMapper + */ + public function createProcessResultMapper() + { + return new ProcessResultMapper(); + } +} diff --git a/src/SprykerMiddleware/Zed/Report/Business/ReportFacade.php b/src/SprykerMiddleware/Zed/Report/Business/ReportFacade.php new file mode 100644 index 0000000..2582dc4 --- /dev/null +++ b/src/SprykerMiddleware/Zed/Report/Business/ReportFacade.php @@ -0,0 +1,24 @@ +getFactory() + ->createProcessResult() + ->saveProcessResult($processResultTransfer); + } +} diff --git a/src/SprykerMiddleware/Zed/Report/Business/ReportFacadeInterface.php b/src/SprykerMiddleware/Zed/Report/Business/ReportFacadeInterface.php new file mode 100644 index 0000000..bf51f8a --- /dev/null +++ b/src/SprykerMiddleware/Zed/Report/Business/ReportFacadeInterface.php @@ -0,0 +1,15 @@ +getFacade() + ->saveProcessResult($processResultTransfer); + } +} diff --git a/src/SprykerMiddleware/Zed/Report/Persistence/Mapper/ProcessResultMapper.php b/src/SprykerMiddleware/Zed/Report/Persistence/Mapper/ProcessResultMapper.php new file mode 100644 index 0000000..3a47efe --- /dev/null +++ b/src/SprykerMiddleware/Zed/Report/Persistence/Mapper/ProcessResultMapper.php @@ -0,0 +1,45 @@ +setItemsProcessedCount($processResultTransfer->getProcessedCount()); + $processResultEntityTransfer->setItemsFailedCount($processResultTransfer->getFailedCount()); + $processResultEntityTransfer->setItemsSkippedCount($processResultTransfer->getSkippedCount()); + $processResultEntityTransfer->setItemsCount($processResultTransfer->getItemCount()); + $processResultEntityTransfer->setStartTime($processResultTransfer->getStartTime()); + $processResultEntityTransfer->setEndTime($processResultTransfer->getEndTime()); + + return $processResultEntityTransfer; + } + + /** + * @param \Generated\Shared\Transfer\SpyProcessResultEntityTransfer $processResultEntityTransfer + * + * @return \Generated\Shared\Transfer\ProcessResultTransfer + */ + public function mapEntityTransferToProcessResultTransfer(SpyProcessResultEntityTransfer $processResultEntityTransfer): ProcessResultTransfer + { + $processResultTransfer = new ProcessResultTransfer(); + $processResultTransfer->setProcessedCount($processResultEntityTransfer->getItemsProcessedCount()); + $processResultTransfer->setFailedCount($processResultEntityTransfer->getItemsFailedCount()); + $processResultTransfer->setSkippedCount($processResultEntityTransfer->getItemsSkippedCount()); + $processResultTransfer->setItemCount($processResultEntityTransfer->getItemsCount()); + $processResultTransfer->setStartTime($processResultEntityTransfer->getStartTime()); + $processResultTransfer->setEndTime($processResultEntityTransfer->getEndTime()); + + return $processResultTransfer; + } +} diff --git a/src/SprykerMiddleware/Zed/Report/Persistence/Propel/Schema/spy_report.schema.xml b/src/SprykerMiddleware/Zed/Report/Persistence/Propel/Schema/spy_report.schema.xml new file mode 100644 index 0000000..2f73eed --- /dev/null +++ b/src/SprykerMiddleware/Zed/Report/Persistence/Propel/Schema/spy_report.schema.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+ +
\ No newline at end of file diff --git a/src/SprykerMiddleware/Zed/Report/Persistence/ReportEntityManager.php b/src/SprykerMiddleware/Zed/Report/Persistence/ReportEntityManager.php new file mode 100644 index 0000000..12ca81d --- /dev/null +++ b/src/SprykerMiddleware/Zed/Report/Persistence/ReportEntityManager.php @@ -0,0 +1,50 @@ +getFactory() + ->createProcessQuery() + ->filterByProcessName($spyProcessEntityTransfer->getProcessName()) + ->findOneOrCreate(); + + $spyProcess->save(); + $spyProcessEntityTransfer->setIdProcess($spyProcess->getIdProcess()); + + return $spyProcessEntityTransfer; + } + + public function saveProcessResult( + ProcessResultTransfer $processResultTransfer, + SpyProcessEntityTransfer $spyProcessEntityTransfer + ): ProcessResultTransfer { + + $entityTransfer = $this->getFactory() + ->createProcessResultMapper() + ->mapProcessResultTransferToEntityTransfer($processResultTransfer); + + $entityTransfer->setFkProcessId($spyProcessEntityTransfer->getIdProcess()); + + $entityTransfer = $this->save($entityTransfer); + + return $this->getFactory() + ->createProcessResultMapper() + ->mapEntityTransferToProcessResultTransfer($entityTransfer); + } +} diff --git a/src/SprykerMiddleware/Zed/Report/Persistence/ReportEntityManagerInterface.php b/src/SprykerMiddleware/Zed/Report/Persistence/ReportEntityManagerInterface.php new file mode 100644 index 0000000..9b3cf20 --- /dev/null +++ b/src/SprykerMiddleware/Zed/Report/Persistence/ReportEntityManagerInterface.php @@ -0,0 +1,24 @@ + Date: Thu, 22 Mar 2018 19:01:04 +0200 Subject: [PATCH 02/25] SM-14: Base process report functionality --- .../Report/Business/Model/ProcessResult.php | 20 +++ .../Report/Business/ReportBusinessFactory.php | 3 + .../Zed/Report/Business/ReportFacade.php | 24 +++ .../Report/Business/ReportFacadeInterface.php | 14 ++ .../Controller/ProcessController.php | 48 +++++ .../Controller/ReportController.php | 35 ++++ .../Controller/ResultController.php | 56 ++++++ .../Hook/ReportPostProcessorHookPlugin.php | 1 + .../ReportCommunicationFactory.php | 46 +++++ .../Table/ProcessResultsTable.php | 169 ++++++++++++++++++ .../Communication/Table/ProcessesTable.php | 106 +++++++++++ .../Zed/Report/Communication/navigation.xml | 35 ++++ .../Service/ReportToUtilEncodingBridge.php | 45 +++++ .../Service/ReportToUtilEncodingInterface.php | 25 +++ .../Mapper/ProcessResultMapper.php | 75 +++++++- .../Propel/Schema/spy_report.schema.xml | 11 +- .../Persistence/ReportEntityManager.php | 6 + .../Persistence/ReportPersistenceFactory.php | 11 +- .../Report/Persistence/ReportRepository.php | 32 ++++ .../Persistence/ReportRepositoryInterface.php | 13 ++ .../Report/Presentation/Process/index.twig | 26 +++ .../Zed/Report/Presentation/Report/index.twig | 13 ++ .../Zed/Report/Presentation/Result/index.twig | 69 +++++++ .../Zed/Report/ReportDependencyProvider.php | 88 +++++++++ 24 files changed, 957 insertions(+), 14 deletions(-) create mode 100644 src/SprykerMiddleware/Zed/Report/Communication/Controller/ProcessController.php create mode 100644 src/SprykerMiddleware/Zed/Report/Communication/Controller/ReportController.php create mode 100644 src/SprykerMiddleware/Zed/Report/Communication/Controller/ResultController.php create mode 100644 src/SprykerMiddleware/Zed/Report/Communication/ReportCommunicationFactory.php create mode 100644 src/SprykerMiddleware/Zed/Report/Communication/Table/ProcessResultsTable.php create mode 100644 src/SprykerMiddleware/Zed/Report/Communication/Table/ProcessesTable.php create mode 100644 src/SprykerMiddleware/Zed/Report/Communication/navigation.xml create mode 100644 src/SprykerMiddleware/Zed/Report/Dependency/Service/ReportToUtilEncodingBridge.php create mode 100644 src/SprykerMiddleware/Zed/Report/Dependency/Service/ReportToUtilEncodingInterface.php create mode 100644 src/SprykerMiddleware/Zed/Report/Presentation/Process/index.twig create mode 100644 src/SprykerMiddleware/Zed/Report/Presentation/Report/index.twig create mode 100644 src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig create mode 100644 src/SprykerMiddleware/Zed/Report/ReportDependencyProvider.php diff --git a/src/SprykerMiddleware/Zed/Report/Business/Model/ProcessResult.php b/src/SprykerMiddleware/Zed/Report/Business/Model/ProcessResult.php index 3f5f7e3..9cb3b3e 100644 --- a/src/SprykerMiddleware/Zed/Report/Business/Model/ProcessResult.php +++ b/src/SprykerMiddleware/Zed/Report/Business/Model/ProcessResult.php @@ -44,4 +44,24 @@ public function saveProcessResult(ProcessResultTransfer $processResultTransfer) return $this->reportEntityManager->saveProcessResult($processResultTransfer, $spyProcessEntityTransfer); } + + /** + * @param int $idResult + * + * @return mixed + */ + public function findProcessResultByResultId(int $idResult) + { + return $this->reportRepository->findProcessResultByResultId($idResult); + } + + /** + * @param int $idProcess + * + * @return mixed + */ + public function findProcessByProcessId(int $idProcess) + { + return $this->reportRepository->findProcessByProcessId($idProcess); + } } diff --git a/src/SprykerMiddleware/Zed/Report/Business/ReportBusinessFactory.php b/src/SprykerMiddleware/Zed/Report/Business/ReportBusinessFactory.php index 8425eb6..f96f1d7 100644 --- a/src/SprykerMiddleware/Zed/Report/Business/ReportBusinessFactory.php +++ b/src/SprykerMiddleware/Zed/Report/Business/ReportBusinessFactory.php @@ -12,6 +12,9 @@ */ class ReportBusinessFactory extends AbstractBusinessFactory { + /** + * @return \SprykerMiddleware\Zed\Report\Business\Model\ProcessResult + */ public function createProcessResult() { return new ProcessResult( diff --git a/src/SprykerMiddleware/Zed/Report/Business/ReportFacade.php b/src/SprykerMiddleware/Zed/Report/Business/ReportFacade.php index 2582dc4..47f5b0d 100644 --- a/src/SprykerMiddleware/Zed/Report/Business/ReportFacade.php +++ b/src/SprykerMiddleware/Zed/Report/Business/ReportFacade.php @@ -21,4 +21,28 @@ public function saveProcessResult(ProcessResultTransfer $processResultTransfer) ->createProcessResult() ->saveProcessResult($processResultTransfer); } + + /** + * @param int $idResult + * + * @return \Generated\Shared\Transfer\ProcessResultTransfer|mixed + */ + public function findProcessResultByResultId(int $idResult) + { + return $this->getFactory() + ->createProcessResult() + ->findProcessResultByResultId($idResult); + } + + /** + * @param int $idProcess + * + * @return mixed + */ + public function findProcessByProcessId(int $idProcess) + { + return $this->getFactory() + ->createProcessResult() + ->findProcessByProcessId($idProcess); + } } diff --git a/src/SprykerMiddleware/Zed/Report/Business/ReportFacadeInterface.php b/src/SprykerMiddleware/Zed/Report/Business/ReportFacadeInterface.php index bf51f8a..4b339ca 100644 --- a/src/SprykerMiddleware/Zed/Report/Business/ReportFacadeInterface.php +++ b/src/SprykerMiddleware/Zed/Report/Business/ReportFacadeInterface.php @@ -12,4 +12,18 @@ interface ReportFacadeInterface * @return void */ public function saveProcessResult(ProcessResultTransfer $processResultTransfer); + + /** + * @param int $idResult + * + * @return \Generated\Shared\Transfer\ProcessResultTransfer + */ + public function findProcessResultByResultId(int $idResult); + + /** + * @param int $idProcess + * + * @return mixed + */ + public function findProcessByProcessId(int $idProcess); } diff --git a/src/SprykerMiddleware/Zed/Report/Communication/Controller/ProcessController.php b/src/SprykerMiddleware/Zed/Report/Communication/Controller/ProcessController.php new file mode 100644 index 0000000..31cbd09 --- /dev/null +++ b/src/SprykerMiddleware/Zed/Report/Communication/Controller/ProcessController.php @@ -0,0 +1,48 @@ +castId($request->query->get(static::URL_PARAM_ID_PROCESS)); + $table = $this->getFactory()->createProcessResultsTable($idProcess); + + $processResult = $this->getFacade()->findProcessByProcessId($idProcess); + + $process['Process Id'] = $processResult->getIdProcess(); + $process['Process Name'] = $processResult->getProcessName(); + + return $this->viewResponse([ + 'processResultsTable' => $table->render(), + 'process' => $process, + ]); + } + + /** + * @return \Symfony\Component\HttpFoundation\JsonResponse + */ + public function tableAction(Request $request) + { + $idProcess = $this->castId($request->query->get(static::URL_PARAM_ID_PROCESS)); + $table = $this->getFactory() + ->createProcessResultsTable($idProcess); + + return $this->jsonResponse($table->fetchData()); + } +} diff --git a/src/SprykerMiddleware/Zed/Report/Communication/Controller/ReportController.php b/src/SprykerMiddleware/Zed/Report/Communication/Controller/ReportController.php new file mode 100644 index 0000000..b4ca64f --- /dev/null +++ b/src/SprykerMiddleware/Zed/Report/Communication/Controller/ReportController.php @@ -0,0 +1,35 @@ +getFactory()->createProcessesTable(); + + return $this->viewResponse([ + 'processesTable' => $table->render(), + ]); + } + + /** + * @return \Symfony\Component\HttpFoundation\JsonResponse + */ + public function tableAction() + { + $table = $this->getFactory() + ->createProcessesTable(); + + return $this->jsonResponse($table->fetchData()); + } +} diff --git a/src/SprykerMiddleware/Zed/Report/Communication/Controller/ResultController.php b/src/SprykerMiddleware/Zed/Report/Communication/Controller/ResultController.php new file mode 100644 index 0000000..074883b --- /dev/null +++ b/src/SprykerMiddleware/Zed/Report/Communication/Controller/ResultController.php @@ -0,0 +1,56 @@ +castId($request->query->get(static::URL_PARAM_ID_RESULT)); + + $processResult = $this->getFacade()->findProcessResultByResultId($idResult); + + $attributes = []; + $attributes['Start Time'] = $processResult->getStartTime(); + $attributes['End Time'] = $processResult->getEndTime(); + $attributes['Item Count'] = $processResult->getItemCount(); + $attributes['Processed Item Count'] = $processResult->getProcessedItemCount(); + $attributes['Skipped Item Count'] = $processResult->getSkippedItemCount(); + $attributes['Failed Item Count'] = $processResult->getFailedItemCount(); + + $stageResultsTransfer = $processResult->getStageResults(); + + $stageResults = []; + + /** @var \Orm\Zed\Report\Persistence\SpyProcessResult $item */ + foreach ($stageResultsTransfer as $stageResult) { + $stageResults[] = [ + 'stage_name' => $stageResult->getStageName(), + 'input_item_count' => $stageResult->getInputItemCount(), + 'output_item_count' => $stageResult->getOutputItemCount(), + 'total_execution_time' => gmdate("H:i:s", round($stageResult->getTotalExecutionTime() * 0.0001)) . ' (H:i:s)', + 'average_time_per_item' => gmdate("H:i:s", round(($stageResult->getTotalExecutionTime() / $stageResult->getInputItemCount() * 0.0001))) . ' (H:i:s)', + ]; + } + + return $this->viewResponse([ + 'processResultAttributes' => $attributes, + 'processConfiguration' => $processResult->getProcessConfiguration()->toArray(), + 'stageResults' => $stageResults, + ]); + } +} diff --git a/src/SprykerMiddleware/Zed/Report/Communication/Plugin/Hook/ReportPostProcessorHookPlugin.php b/src/SprykerMiddleware/Zed/Report/Communication/Plugin/Hook/ReportPostProcessorHookPlugin.php index 6b3c633..3042728 100644 --- a/src/SprykerMiddleware/Zed/Report/Communication/Plugin/Hook/ReportPostProcessorHookPlugin.php +++ b/src/SprykerMiddleware/Zed/Report/Communication/Plugin/Hook/ReportPostProcessorHookPlugin.php @@ -8,6 +8,7 @@ /** * @method \SprykerMiddleware\Zed\Report\Business\ReportFacadeInterface getFacade() + * @method \SprykerMiddleware\Zed\Report\Communication\ReportCommunicationFactory getFactory() */ class ReportPostProcessorHookPlugin extends AbstractPlugin implements PostProcessorHookPluginInterface { diff --git a/src/SprykerMiddleware/Zed/Report/Communication/ReportCommunicationFactory.php b/src/SprykerMiddleware/Zed/Report/Communication/ReportCommunicationFactory.php new file mode 100644 index 0000000..0802947 --- /dev/null +++ b/src/SprykerMiddleware/Zed/Report/Communication/ReportCommunicationFactory.php @@ -0,0 +1,46 @@ +getPropelProcessQuery(); + return new ProcessesTable($processQuery); + } + + /** + * @param int $idProcess + * + * @return \SprykerMiddleware\Zed\Report\Communication\Table\ProcessResultsTable + */ + public function createProcessResultsTable(int $idProcess): ProcessResultsTable + { + $processResultQuery = $this->getPropelProcessResultQuery(); + return new ProcessResultsTable($processResultQuery, $idProcess); + } + + /** + * @return \Orm\Zed\Report\Persistence\SpyProcessQuery + */ + protected function getPropelProcessQuery(): SpyProcessQuery + { + return $this->getProvidedDependency(ReportDependencyProvider::PROPEL_PROCESS_QUERY); + } + + protected function getPropelProcessResultQuery(): SpyProcessResultQuery + { + return $this->getProvidedDependency(ReportDependencyProvider::PROPEL_PROCESS_RESULT_QUERY); + } +} diff --git a/src/SprykerMiddleware/Zed/Report/Communication/Table/ProcessResultsTable.php b/src/SprykerMiddleware/Zed/Report/Communication/Table/ProcessResultsTable.php new file mode 100644 index 0000000..ba1beed --- /dev/null +++ b/src/SprykerMiddleware/Zed/Report/Communication/Table/ProcessResultsTable.php @@ -0,0 +1,169 @@ +processResultQuery = $processResultQuery; + $this->idProcess = $idProcess; + } + + /** + * @param \Spryker\Zed\Gui\Communication\Table\TableConfiguration $config + * + * @return \Spryker\Zed\Gui\Communication\Table\TableConfiguration + */ + protected function configure(TableConfiguration $config) + { + $config->setHeader([ + static::COL_ID_PROCESS_RESULT => 'ID', + static::COL_START_TIME => 'Start Time', + static::TABLE_COL_DURATION => 'Duration', + static::COL_ITEM_COUNT => 'Item Count', + static::TABLE_COL_STATUS => 'Status', + static::TABLE_COL_ACTIONS => static::TABLE_COL_ACTIONS, + ]); + $config->setSearchable([ + static::COL_ID_PROCESS_RESULT, + static::COL_START_TIME, + static::COL_ITEM_COUNT, + ]); + $config->setSortable([ + static::COL_ID_PROCESS_RESULT, + static::COL_START_TIME, + static::COL_ITEM_COUNT, + ]); + $config->setDefaultSortField(static::COL_ID_PROCESS_RESULT, TableConfiguration::SORT_DESC); + $config->addRawColumn(static::TABLE_COL_DURATION); + $config->addRawColumn(static::TABLE_COL_STATUS); + $config->addRawColumn(static::TABLE_COL_ACTIONS); + + $config->setUrl(sprintf('table?id_process=%d', $this->idProcess)); + + return $config; + } + + /** + * @param \Spryker\Zed\Gui\Communication\Table\TableConfiguration $config + * + * @return array + */ + protected function prepareData(TableConfiguration $config) + { + $query = $this->prepareQuery(); + + $queryResults = $this->runQuery($query, $config, true); + $results = []; + + /** @var \Orm\Zed\Report\Persistence\SpyProcessResult $item */ + foreach ($queryResults as $item) { + $results[] = [ + static::COL_ID_PROCESS_RESULT => $item->getIdProcessResult(), + static::COL_START_TIME => $item->getStartTime('Y-m-d h:i:s'), + static::TABLE_COL_DURATION => gmdate("H:i:s", $this->getDuration($item)) . ' (H:i:s)', + static::COL_ITEM_COUNT => $item->getItemCount(), + static::TABLE_COL_STATUS => $this->getStatus($item), + static::TABLE_COL_ACTIONS => $this->getActionButtons($item), + ]; + } + unset($queryResults); + return $results; + } + + protected function prepareQuery() + { + $query = $this->processResultQuery->filterByFkProcessId($this->idProcess); + + return $query; + } + + /** + * @param array $item + * + * @return string + */ + protected function getActionButtons(SpyProcessResult $item) + { + $buttons = []; + $buttons[] = $this->createViewButton($item); + + return implode(' ', $buttons); + } + + /** + * @param \Orm\Zed\Report\Persistence\SpyProcessResult $item + * + * @return \DateTime|string + */ + protected function getDuration(SpyProcessResult $item) + { + if ($item->getEndTime('U') === null) { + return $item->getCreatedAt('U') - $item->getStartTime('U'); + } + return $item->getEndTime('U') - $item->getStartTime('U'); + } + + /** + * @param \Orm\Zed\Report\Persistence\SpyProcessResult $item + * + * @return string + */ + protected function getStatus(SpyProcessResult $item) + { + if ($item->getFailedItemCount() > 0) { + return 'Failed'; + } + + if ($item->getSkippedItemCount() > 0) { + return 'Were skipped items'; + } + + return 'Success'; + } + + /** + * @param array $item + * + * @return string + */ + protected function createViewButton(SpyProcessResult $item) + { + $viewDiscountUrl = Url::generate( + '/report/result/index', + [ + static::URL_PARAM_ID_RESULT => $item->getIdProcessResult(), + ] + ); + + return $this->generateViewButton($viewDiscountUrl, 'Details'); + } +} diff --git a/src/SprykerMiddleware/Zed/Report/Communication/Table/ProcessesTable.php b/src/SprykerMiddleware/Zed/Report/Communication/Table/ProcessesTable.php new file mode 100644 index 0000000..04b9ae9 --- /dev/null +++ b/src/SprykerMiddleware/Zed/Report/Communication/Table/ProcessesTable.php @@ -0,0 +1,106 @@ +processQuery = $processQuery; + } + + /** + * @param \Spryker\Zed\Gui\Communication\Table\TableConfiguration $config + * + * @return \Spryker\Zed\Gui\Communication\Table\TableConfiguration + */ + protected function configure(TableConfiguration $config) + { + $config->setHeader([ + static::COL_ID_PROCESS => 'ID', + static::COL_PROCESS_NAME => 'Process', + static::TABLE_COL_ACTIONS => static::TABLE_COL_ACTIONS, + ]); + $config->setSearchable([ + static::COL_ID_PROCESS, + static::COL_PROCESS_NAME, + ]); + $config->setSortable([ + static::COL_ID_PROCESS, + static::COL_PROCESS_NAME, + ]); + $config->addRawColumn(static::TABLE_COL_ACTIONS); + + return $config; + } + + /** + * @param \Spryker\Zed\Gui\Communication\Table\TableConfiguration $config + * + * @return array + */ + protected function prepareData(TableConfiguration $config) + { + $queryResults = $this->runQuery($this->processQuery, $config); + $results = []; + + foreach ($queryResults as $item) { + $results[] = [ + static::COL_ID_PROCESS => $item[SpyProcessTableMap::COL_ID_PROCESS], + static::COL_PROCESS_NAME => $item[SpyProcessTableMap::COL_PROCESS_NAME], + static::TABLE_COL_ACTIONS => $this->getActionButtons($item), + ]; + } + unset($queryResults); + return $results; + } + + /** + * @param array $item + * + * @return string + */ + protected function getActionButtons(array $item) + { + $buttons = []; + $buttons[] = $this->createViewButton($item); + + return implode(' ', $buttons); + } + + /** + * @param array $item + * + * @return string + */ + protected function createViewButton(array $item) + { + $viewDiscountUrl = Url::generate( + '/report/process/index', + [ + ProcessController::URL_PARAM_ID_PROCESS => $item[SpyProcessTableMap::COL_ID_PROCESS], + ] + ); + + return $this->generateViewButton($viewDiscountUrl, 'View'); + } +} diff --git a/src/SprykerMiddleware/Zed/Report/Communication/navigation.xml b/src/SprykerMiddleware/Zed/Report/Communication/navigation.xml new file mode 100644 index 0000000..1ba191e --- /dev/null +++ b/src/SprykerMiddleware/Zed/Report/Communication/navigation.xml @@ -0,0 +1,35 @@ + + + + + + + Middleware Reports + report + report + index + fa-line-chart + + + + Process Results + report + process + index + 0 + +
+ + Result Details + report + result + index + 0 +
+
+
+
+
+
+
+
diff --git a/src/SprykerMiddleware/Zed/Report/Dependency/Service/ReportToUtilEncodingBridge.php b/src/SprykerMiddleware/Zed/Report/Dependency/Service/ReportToUtilEncodingBridge.php new file mode 100644 index 0000000..d2496c9 --- /dev/null +++ b/src/SprykerMiddleware/Zed/Report/Dependency/Service/ReportToUtilEncodingBridge.php @@ -0,0 +1,45 @@ +utilEncodingService = $utilEncodingService; + } + + /** + * @param mixed $value + * @param int|null $options + * @param int|null $depth + * + * @return string + */ + public function encodeJson($value, $options = null, $depth = null) + { + return $this->utilEncodingService->encodeJson($value, $options, $depth); + } + + /** + * @param string $jsonValue + * @param bool $assoc + * @param int|null $depth + * @param int|null $options + * + * @return array + */ + public function decodeJson($jsonValue, $assoc = false, $depth = null, $options = null) + { + return $this->utilEncodingService->decodeJson($jsonValue, $assoc, $depth, $options); + } +} diff --git a/src/SprykerMiddleware/Zed/Report/Dependency/Service/ReportToUtilEncodingInterface.php b/src/SprykerMiddleware/Zed/Report/Dependency/Service/ReportToUtilEncodingInterface.php new file mode 100644 index 0000000..6a3ad32 --- /dev/null +++ b/src/SprykerMiddleware/Zed/Report/Dependency/Service/ReportToUtilEncodingInterface.php @@ -0,0 +1,25 @@ +utilEncoding = $utilEncoding; + } + /** * @param \Generated\Shared\Transfer\ProcessResultTransfer $processResultTransfer * @@ -15,13 +29,18 @@ class ProcessResultMapper public function mapProcessResultTransferToEntityTransfer(ProcessResultTransfer $processResultTransfer): SpyProcessResultEntityTransfer { $processResultEntityTransfer = new SpyProcessResultEntityTransfer(); - $processResultEntityTransfer->setItemsProcessedCount($processResultTransfer->getProcessedCount()); - $processResultEntityTransfer->setItemsFailedCount($processResultTransfer->getFailedCount()); - $processResultEntityTransfer->setItemsSkippedCount($processResultTransfer->getSkippedCount()); - $processResultEntityTransfer->setItemsCount($processResultTransfer->getItemCount()); + $processResultEntityTransfer->setProcessedItemCount($processResultTransfer->getProcessedItemCount()); + $processResultEntityTransfer->setFailedItemCount($processResultTransfer->getFailedItemCount()); + $processResultEntityTransfer->setSkippedItemCount($processResultTransfer->getSkippedItemCount()); + $processResultEntityTransfer->setItemCount($processResultTransfer->getItemCount()); $processResultEntityTransfer->setStartTime($processResultTransfer->getStartTime()); $processResultEntityTransfer->setEndTime($processResultTransfer->getEndTime()); + $stagesResults = $this->mapStagesResultToArray($processResultTransfer->getStageResults()); + $processResultEntityTransfer->setStageResults($this->utilEncoding->encodeJson($stagesResults)); + + $processResultEntityTransfer->setProcessConfiguration($this->utilEncoding->encodeJson($processResultTransfer->getProcessConfiguration()->toArray())); + return $processResultEntityTransfer; } @@ -33,13 +52,53 @@ public function mapProcessResultTransferToEntityTransfer(ProcessResultTransfer $ public function mapEntityTransferToProcessResultTransfer(SpyProcessResultEntityTransfer $processResultEntityTransfer): ProcessResultTransfer { $processResultTransfer = new ProcessResultTransfer(); - $processResultTransfer->setProcessedCount($processResultEntityTransfer->getItemsProcessedCount()); - $processResultTransfer->setFailedCount($processResultEntityTransfer->getItemsFailedCount()); - $processResultTransfer->setSkippedCount($processResultEntityTransfer->getItemsSkippedCount()); - $processResultTransfer->setItemCount($processResultEntityTransfer->getItemsCount()); + $processResultTransfer->setProcessedItemCount($processResultEntityTransfer->getProcessedItemCount()); + $processResultTransfer->setFailedItemCount($processResultEntityTransfer->getFailedItemCount()); + $processResultTransfer->setSkippedItemCount($processResultEntityTransfer->getSkippedItemCount()); + $processResultTransfer->setItemCount($processResultEntityTransfer->getItemCount()); $processResultTransfer->setStartTime($processResultEntityTransfer->getStartTime()); $processResultTransfer->setEndTime($processResultEntityTransfer->getEndTime()); + $stages = $this->mapArrayToStagesResult($this->utilEncoding->decodeJson($processResultEntityTransfer->getStageResults(), true)); + $processResultTransfer->setStageResults($stages); + + $conf = new ProcessConfigurationTransfer(); + $conf->fromArray($this->utilEncoding->decodeJson($processResultEntityTransfer->getProcessConfiguration(), true)); + $processResultTransfer->setProcessConfiguration($conf); + return $processResultTransfer; } + + /** + * @param \ArrayObject $stagesResults + * + * @return array + */ + public function mapStagesResultToArray(ArrayObject $stagesResults) + { + $stagesResultsArray = []; + + foreach ($stagesResults as $stage) { + $stagesResultsArray[] = $stage->toArray(); + } + return $stagesResultsArray; + } + + /** + * @param array $stagesResults + * + * @return \ArrayObject + */ + public function mapArrayToStagesResult(array $stagesResults) + { + $res = new ArrayObject(); + foreach ($stagesResults as $stage) { + $stagesResultsTransfer = new StageResultsTransfer(); + $stagesResultsTransfer->fromArray($stage); + + $res->append($stagesResultsTransfer); + } + + return $res; + } } diff --git a/src/SprykerMiddleware/Zed/Report/Persistence/Propel/Schema/spy_report.schema.xml b/src/SprykerMiddleware/Zed/Report/Persistence/Propel/Schema/spy_report.schema.xml index 2f73eed..944a483 100644 --- a/src/SprykerMiddleware/Zed/Report/Persistence/Propel/Schema/spy_report.schema.xml +++ b/src/SprykerMiddleware/Zed/Report/Persistence/Propel/Schema/spy_report.schema.xml @@ -17,13 +17,14 @@ - - - - + + + + - + + diff --git a/src/SprykerMiddleware/Zed/Report/Persistence/ReportEntityManager.php b/src/SprykerMiddleware/Zed/Report/Persistence/ReportEntityManager.php index 12ca81d..2c0214b 100644 --- a/src/SprykerMiddleware/Zed/Report/Persistence/ReportEntityManager.php +++ b/src/SprykerMiddleware/Zed/Report/Persistence/ReportEntityManager.php @@ -30,6 +30,12 @@ public function saveProcess(SpyProcessEntityTransfer $spyProcessEntityTransfer) return $spyProcessEntityTransfer; } + /** + * @param \Generated\Shared\Transfer\ProcessResultTransfer $processResultTransfer + * @param \Generated\Shared\Transfer\SpyProcessEntityTransfer $spyProcessEntityTransfer + * + * @return \Generated\Shared\Transfer\ProcessResultTransfer + */ public function saveProcessResult( ProcessResultTransfer $processResultTransfer, SpyProcessEntityTransfer $spyProcessEntityTransfer diff --git a/src/SprykerMiddleware/Zed/Report/Persistence/ReportPersistenceFactory.php b/src/SprykerMiddleware/Zed/Report/Persistence/ReportPersistenceFactory.php index 7faaed6..5c78a9d 100644 --- a/src/SprykerMiddleware/Zed/Report/Persistence/ReportPersistenceFactory.php +++ b/src/SprykerMiddleware/Zed/Report/Persistence/ReportPersistenceFactory.php @@ -6,6 +6,7 @@ use Orm\Zed\Report\Persistence\SpyProcessResultQuery; use Spryker\Zed\Kernel\Persistence\AbstractPersistenceFactory; use SprykerMiddleware\Zed\Report\Persistence\Mapper\ProcessResultMapper; +use SprykerMiddleware\Zed\Report\ReportDependencyProvider; class ReportPersistenceFactory extends AbstractPersistenceFactory { @@ -27,6 +28,14 @@ public function createProcessResultQuery(): SpyProcessResultQuery public function createProcessResultMapper() { - return new ProcessResultMapper(); + return new ProcessResultMapper($this->getUtilEncodingService()); + } + + /** + * @return \SprykerMiddleware\Zed\Report\Dependency\Service\ReportToUtilEncodingInterface + */ + public function getUtilEncodingService() + { + return $this->getProvidedDependency(ReportDependencyProvider::SERVICE_UTIL_ENCODING); } } diff --git a/src/SprykerMiddleware/Zed/Report/Persistence/ReportRepository.php b/src/SprykerMiddleware/Zed/Report/Persistence/ReportRepository.php index 3008d88..30f18f5 100644 --- a/src/SprykerMiddleware/Zed/Report/Persistence/ReportRepository.php +++ b/src/SprykerMiddleware/Zed/Report/Persistence/ReportRepository.php @@ -9,4 +9,36 @@ */ class ReportRepository extends AbstractRepository implements ReportRepositoryInterface { + /** + * @param int $idResult + * + * @return \Generated\Shared\Transfer\ProcessResultTransfer|null + */ + public function findProcessResultByResultId(int $idResult) + { + $query = $this->getFactory() + ->createProcessResultQuery() + ->filterByIdProcessResult($idResult); + + $entityTransfer = $this->buildQueryFromCriteria($query)->findOne(); + + if ($entityTransfer !== null) { + return $this->getFactory() + ->createProcessResultMapper() + ->mapEntityTransferToProcessResultTransfer($entityTransfer); + } + + return null; + } + + /** + * @param int $idProcess + * + * @return mixed + */ + public function findProcessByProcessId(int $idProcess) + { + $query = $this->getFactory()->createProcessQuery()->filterByIdProcess($idProcess); + return $this->buildQueryFromCriteria($query)->findOne(); + } } diff --git a/src/SprykerMiddleware/Zed/Report/Persistence/ReportRepositoryInterface.php b/src/SprykerMiddleware/Zed/Report/Persistence/ReportRepositoryInterface.php index 7a9a40c..4a805ba 100644 --- a/src/SprykerMiddleware/Zed/Report/Persistence/ReportRepositoryInterface.php +++ b/src/SprykerMiddleware/Zed/Report/Persistence/ReportRepositoryInterface.php @@ -4,4 +4,17 @@ interface ReportRepositoryInterface { + /** + * @param int $idResult + * + * @return mixed + */ + public function findProcessResultByResultId(int $idResult); + + /** + * @param int $idProcess + * + * @return mixed + */ + public function findProcessByProcessId(int $idProcess); } diff --git a/src/SprykerMiddleware/Zed/Report/Presentation/Process/index.twig b/src/SprykerMiddleware/Zed/Report/Presentation/Process/index.twig new file mode 100644 index 0000000..7ae362e --- /dev/null +++ b/src/SprykerMiddleware/Zed/Report/Presentation/Process/index.twig @@ -0,0 +1,26 @@ +{% extends '@Gui/Layout/layout.twig' %} + +{% block content %} + + {% embed '@Gui/Partials/widget.twig' with { widget_title: 'Process Results' | trans } %} + + {% block widget_content %} +

{{ 'Process' | trans }}

+
+ {% for key, item in process %} + + + + + + {% endfor %} + +
{{ key | replace({'_': " "}) }} + {{ item | raw }} +
+ {{ processResultsTable | raw }} + {% endblock %} + + {% endembed %} + +{% endblock %} \ No newline at end of file diff --git a/src/SprykerMiddleware/Zed/Report/Presentation/Report/index.twig b/src/SprykerMiddleware/Zed/Report/Presentation/Report/index.twig new file mode 100644 index 0000000..f02d2db --- /dev/null +++ b/src/SprykerMiddleware/Zed/Report/Presentation/Report/index.twig @@ -0,0 +1,13 @@ +{% extends '@Gui/Layout/layout.twig' %} + +{% block content %} + + {% embed '@Gui/Partials/widget.twig' with { widget_title: 'Processes List' | trans } %} + + {% block widget_content %} + {{ processesTable | raw }} + {% endblock %} + + {% endembed %} + +{% endblock %} \ No newline at end of file diff --git a/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig b/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig new file mode 100644 index 0000000..1845967 --- /dev/null +++ b/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig @@ -0,0 +1,69 @@ +{% extends '@Gui/Layout/layout.twig' %} + +{% block content %} + + {% embed '@Gui/Partials/widget.twig' with { widget_title: 'Process Result Details' } %} + + {% block widget_content %} +

{{ 'Process Details' | trans }}

+ + {% for key, item in processResultAttributes %} + + + + + {% endfor %} +
{{ key }} + {{ item | replace({".000000": ""}) }} +
+ +

{{ 'Process Configuration' | trans }}

+ + {% for key, item in processConfiguration %} + + + + + {% endfor %} +
{{ key | replace({'_': " "}) | title }} + {% if item is iterable %} + + {% for k, value in item %} + + + + + {% endfor %} +
{{ k | replace({'_': " "}) | title }}{{ value }}
+ {% else %} + {{ item }} + {% endif %} +
+ +

{{ 'Process Stage Results' | trans }}

+ + + + + + + + + + + {% for item in stageResults %} + + + + + + + + {% endfor %} +
Stage NameInput Item CountOutput Item CountTotal Execution TimeAverage Item Execution Time
{{ item.stage_name }}{{ item.input_item_count }}{{ item.output_item_count }}{{ item.total_execution_time }}{{ item.average_time_per_item }}
+ + {% endblock %} + + {% endembed %} + +{% endblock %} \ No newline at end of file diff --git a/src/SprykerMiddleware/Zed/Report/ReportDependencyProvider.php b/src/SprykerMiddleware/Zed/Report/ReportDependencyProvider.php new file mode 100644 index 0000000..78739c9 --- /dev/null +++ b/src/SprykerMiddleware/Zed/Report/ReportDependencyProvider.php @@ -0,0 +1,88 @@ +addPropelProcessQuery($container); + $container = $this->addPropelProcessResultQuery($container); + + return $container; + } + + /** + * @param \Spryker\Zed\Kernel\Container $container + * + * @return \Spryker\Zed\Kernel\Container + */ + protected function addPropelProcessQuery(Container $container): Container + { + $container[static::PROPEL_PROCESS_QUERY] = function (Container $container) { + return SpyProcessQuery::create(); + }; + + return $container; + } + + /** + * @param \Spryker\Zed\Kernel\Container $container + * + * @return \Spryker\Zed\Kernel\Container + */ + protected function addPropelProcessResultQuery(Container $container): Container + { + $container[static::PROPEL_PROCESS_RESULT_QUERY] = function (Container $container) { + return SpyProcessResultQuery::create(); + }; + + return $container; + } + + /** + * @param \Spryker\Zed\Kernel\Container $container + * + * @return \Spryker\Zed\Kernel\Container + */ + protected function addServiceUtilEncoding(Container $container) + { + $container[static::SERVICE_UTIL_ENCODING] = function (Container $container) { + return new ReportToUtilEncodingBridge( + $container->getLocator()->utilEncoding()->service() + ); + }; + + return $container; + } + + /** + * @param \Spryker\Zed\Kernel\Container $container + * + * @return \Spryker\Zed\Kernel\Container + */ + public function providePersistenceLayerDependencies(Container $container) + { + $container = $this->addServiceUtilEncoding($container); + + return $container; + } +} From da86fc43b4e06f04e9532ee414aca3bb8c879e69 Mon Sep 17 00:00:00 2001 From: Oleh Okhremchuk Date: Fri, 23 Mar 2018 17:14:22 +0200 Subject: [PATCH 03/25] SM-14: code style fixes --- .../Process/Transfer/process.transfer.xml | 40 ++++++ .../Report/Business/Model/ProcessResult.php | 10 +- .../Business/Model/ProcessResultInterface.php | 17 ++- .../Report/Business/ReportBusinessFactory.php | 11 +- .../Zed/Report/Business/ReportFacade.php | 15 +-- .../Report/Business/ReportFacadeInterface.php | 11 +- .../Controller/ProcessController.php | 13 +- .../Controller/ReportController.php | 5 +- .../Controller/ResultController.php | 31 +---- .../ReportCommunicationFactory.php | 5 +- .../Table/ProcessResultsTable.php | 42 ++++--- .../Communication/Table/ProcessesTable.php | 8 +- .../Zed/Report/Communication/navigation.xml | 18 ++- .../Service/ReportToUtilEncodingBridge.php | 4 +- .../Service/ReportToUtilEncodingInterface.php | 4 +- .../Mapper/ProcessResultMapper.php | 18 +-- .../Persistence/ReportEntityManager.php | 4 +- .../ReportEntityManagerInterface.php | 12 +- .../Persistence/ReportPersistenceFactory.php | 12 +- .../Report/Persistence/ReportRepository.php | 8 +- .../Persistence/ReportRepositoryInterface.php | 11 +- .../Zed/Report/Presentation/Result/index.twig | 118 +++++++++++++----- .../Zed/Report/ReportDependencyProvider.php | 12 +- 23 files changed, 264 insertions(+), 165 deletions(-) create mode 100644 src/SprykerMiddleware/Shared/Process/Transfer/process.transfer.xml diff --git a/src/SprykerMiddleware/Shared/Process/Transfer/process.transfer.xml b/src/SprykerMiddleware/Shared/Process/Transfer/process.transfer.xml new file mode 100644 index 0000000..512a2a4 --- /dev/null +++ b/src/SprykerMiddleware/Shared/Process/Transfer/process.transfer.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/SprykerMiddleware/Zed/Report/Business/Model/ProcessResult.php b/src/SprykerMiddleware/Zed/Report/Business/Model/ProcessResult.php index 9cb3b3e..6e25007 100644 --- a/src/SprykerMiddleware/Zed/Report/Business/Model/ProcessResult.php +++ b/src/SprykerMiddleware/Zed/Report/Business/Model/ProcessResult.php @@ -36,7 +36,7 @@ public function __construct( * * @return \Generated\Shared\Transfer\ProcessResultTransfer */ - public function saveProcessResult(ProcessResultTransfer $processResultTransfer) + public function saveProcessResult(ProcessResultTransfer $processResultTransfer): ProcessResultTransfer { $spyProcessEntityTransfer = new SpyProcessEntityTransfer(); $spyProcessEntityTransfer->setProcessName($processResultTransfer->getProcessName()); @@ -48,9 +48,9 @@ public function saveProcessResult(ProcessResultTransfer $processResultTransfer) /** * @param int $idResult * - * @return mixed + * @return \Generated\Shared\Transfer\ProcessResultTransfer */ - public function findProcessResultByResultId(int $idResult) + public function findProcessResultByResultId(int $idResult): ProcessResultTransfer { return $this->reportRepository->findProcessResultByResultId($idResult); } @@ -58,9 +58,9 @@ public function findProcessResultByResultId(int $idResult) /** * @param int $idProcess * - * @return mixed + * @return \Generated\Shared\Transfer\SpyProcessEntityTransfer */ - public function findProcessByProcessId(int $idProcess) + public function findProcessByProcessId(int $idProcess): SpyProcessEntityTransfer { return $this->reportRepository->findProcessByProcessId($idProcess); } diff --git a/src/SprykerMiddleware/Zed/Report/Business/Model/ProcessResultInterface.php b/src/SprykerMiddleware/Zed/Report/Business/Model/ProcessResultInterface.php index ad10ff0..f555602 100644 --- a/src/SprykerMiddleware/Zed/Report/Business/Model/ProcessResultInterface.php +++ b/src/SprykerMiddleware/Zed/Report/Business/Model/ProcessResultInterface.php @@ -3,6 +3,7 @@ namespace SprykerMiddleware\Zed\Report\Business\Model; use Generated\Shared\Transfer\ProcessResultTransfer; +use Generated\Shared\Transfer\SpyProcessEntityTransfer; interface ProcessResultInterface { @@ -11,5 +12,19 @@ interface ProcessResultInterface * * @return \Generated\Shared\Transfer\ProcessResultTransfer */ - public function saveProcessResult(ProcessResultTransfer $processResultTransfer); + public function saveProcessResult(ProcessResultTransfer $processResultTransfer): ProcessResultTransfer; + + /** + * @param int $idResult + * + * @return \Generated\Shared\Transfer\ProcessResultTransfer + */ + public function findProcessResultByResultId(int $idResult): ProcessResultTransfer; + + /** + * @param int $idProcess + * + * @return \Generated\Shared\Transfer\SpyProcessEntityTransfer + */ + public function findProcessByProcessId(int $idProcess): SpyProcessEntityTransfer; } diff --git a/src/SprykerMiddleware/Zed/Report/Business/ReportBusinessFactory.php b/src/SprykerMiddleware/Zed/Report/Business/ReportBusinessFactory.php index f96f1d7..2c1844d 100644 --- a/src/SprykerMiddleware/Zed/Report/Business/ReportBusinessFactory.php +++ b/src/SprykerMiddleware/Zed/Report/Business/ReportBusinessFactory.php @@ -4,7 +4,6 @@ use Spryker\Zed\Kernel\Business\AbstractBusinessFactory; use SprykerMiddleware\Zed\Report\Business\Model\ProcessResult; -use SprykerMiddleware\Zed\Report\Persistence\Mapper\ProcessResultMapper; /** * @method \SprykerMiddleware\Zed\Report\Persistence\ReportRepositoryInterface getRepository() @@ -15,19 +14,11 @@ class ReportBusinessFactory extends AbstractBusinessFactory /** * @return \SprykerMiddleware\Zed\Report\Business\Model\ProcessResult */ - public function createProcessResult() + public function createProcessResult(): ProcessResult { return new ProcessResult( $this->getRepository(), $this->getEntityManager() ); } - - /** - * @return \SprykerMiddleware\Zed\Report\Persistence\Mapper\ProcessResultMapper - */ - public function createProcessResultMapper() - { - return new ProcessResultMapper(); - } } diff --git a/src/SprykerMiddleware/Zed/Report/Business/ReportFacade.php b/src/SprykerMiddleware/Zed/Report/Business/ReportFacade.php index 47f5b0d..e83b692 100644 --- a/src/SprykerMiddleware/Zed/Report/Business/ReportFacade.php +++ b/src/SprykerMiddleware/Zed/Report/Business/ReportFacade.php @@ -3,6 +3,7 @@ namespace SprykerMiddleware\Zed\Report\Business; use Generated\Shared\Transfer\ProcessResultTransfer; +use Generated\Shared\Transfer\SpyProcessEntityTransfer; use Spryker\Zed\Kernel\Business\AbstractFacade; /** @@ -13,11 +14,11 @@ class ReportFacade extends AbstractFacade implements ReportFacadeInterface /** * @param \Generated\Shared\Transfer\ProcessResultTransfer $processResultTransfer * - * @return void + * @return \Generated\Shared\Transfer\ProcessResultTransfer */ - public function saveProcessResult(ProcessResultTransfer $processResultTransfer) + public function saveProcessResult(ProcessResultTransfer $processResultTransfer): ProcessResultTransfer { - $this->getFactory() + return $this->getFactory() ->createProcessResult() ->saveProcessResult($processResultTransfer); } @@ -25,9 +26,9 @@ public function saveProcessResult(ProcessResultTransfer $processResultTransfer) /** * @param int $idResult * - * @return \Generated\Shared\Transfer\ProcessResultTransfer|mixed + * @return \Generated\Shared\Transfer\ProcessResultTransfer */ - public function findProcessResultByResultId(int $idResult) + public function findProcessResultByResultId(int $idResult): ProcessResultTransfer { return $this->getFactory() ->createProcessResult() @@ -37,9 +38,9 @@ public function findProcessResultByResultId(int $idResult) /** * @param int $idProcess * - * @return mixed + * @return \Generated\Shared\Transfer\SpyProcessEntityTransfer */ - public function findProcessByProcessId(int $idProcess) + public function findProcessByProcessId(int $idProcess): SpyProcessEntityTransfer { return $this->getFactory() ->createProcessResult() diff --git a/src/SprykerMiddleware/Zed/Report/Business/ReportFacadeInterface.php b/src/SprykerMiddleware/Zed/Report/Business/ReportFacadeInterface.php index 4b339ca..d311d94 100644 --- a/src/SprykerMiddleware/Zed/Report/Business/ReportFacadeInterface.php +++ b/src/SprykerMiddleware/Zed/Report/Business/ReportFacadeInterface.php @@ -3,27 +3,28 @@ namespace SprykerMiddleware\Zed\Report\Business; use Generated\Shared\Transfer\ProcessResultTransfer; +use Generated\Shared\Transfer\SpyProcessEntityTransfer; interface ReportFacadeInterface { /** * @param \Generated\Shared\Transfer\ProcessResultTransfer $processResultTransfer * - * @return void + * @return \Generated\Shared\Transfer\ProcessResultTransfer */ - public function saveProcessResult(ProcessResultTransfer $processResultTransfer); + public function saveProcessResult(ProcessResultTransfer $processResultTransfer): ProcessResultTransfer; /** * @param int $idResult * * @return \Generated\Shared\Transfer\ProcessResultTransfer */ - public function findProcessResultByResultId(int $idResult); + public function findProcessResultByResultId(int $idResult): ProcessResultTransfer; /** * @param int $idProcess * - * @return mixed + * @return \Generated\Shared\Transfer\SpyProcessEntityTransfer */ - public function findProcessByProcessId(int $idProcess); + public function findProcessByProcessId(int $idProcess): SpyProcessEntityTransfer; } diff --git a/src/SprykerMiddleware/Zed/Report/Communication/Controller/ProcessController.php b/src/SprykerMiddleware/Zed/Report/Communication/Controller/ProcessController.php index 31cbd09..5d86577 100644 --- a/src/SprykerMiddleware/Zed/Report/Communication/Controller/ProcessController.php +++ b/src/SprykerMiddleware/Zed/Report/Communication/Controller/ProcessController.php @@ -3,6 +3,7 @@ namespace SprykerMiddleware\Zed\Report\Communication\Controller; use Spryker\Zed\Kernel\Communication\Controller\AbstractController; +use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; /** @@ -18,26 +19,24 @@ class ProcessController extends AbstractController * * @return array */ - public function indexAction(Request $request) + public function indexAction(Request $request): array { $idProcess = $this->castId($request->query->get(static::URL_PARAM_ID_PROCESS)); $table = $this->getFactory()->createProcessResultsTable($idProcess); - $processResult = $this->getFacade()->findProcessByProcessId($idProcess); - $process['Process Id'] = $processResult->getIdProcess(); - $process['Process Name'] = $processResult->getProcessName(); - return $this->viewResponse([ 'processResultsTable' => $table->render(), - 'process' => $process, + 'process' => $processResult, ]); } /** + * @param \Symfony\Component\HttpFoundation\Request $request + * * @return \Symfony\Component\HttpFoundation\JsonResponse */ - public function tableAction(Request $request) + public function tableAction(Request $request): JsonResponse { $idProcess = $this->castId($request->query->get(static::URL_PARAM_ID_PROCESS)); $table = $this->getFactory() diff --git a/src/SprykerMiddleware/Zed/Report/Communication/Controller/ReportController.php b/src/SprykerMiddleware/Zed/Report/Communication/Controller/ReportController.php index b4ca64f..f7ea3e2 100644 --- a/src/SprykerMiddleware/Zed/Report/Communication/Controller/ReportController.php +++ b/src/SprykerMiddleware/Zed/Report/Communication/Controller/ReportController.php @@ -3,6 +3,7 @@ namespace SprykerMiddleware\Zed\Report\Communication\Controller; use Spryker\Zed\Kernel\Communication\Controller\AbstractController; +use Symfony\Component\HttpFoundation\JsonResponse; /** * @method \SprykerMiddleware\Zed\Report\Business\ReportFacadeInterface getFacade() @@ -13,7 +14,7 @@ class ReportController extends AbstractController /** * @return array */ - public function indexAction() + public function indexAction(): array { $table = $this->getFactory()->createProcessesTable(); @@ -25,7 +26,7 @@ public function indexAction() /** * @return \Symfony\Component\HttpFoundation\JsonResponse */ - public function tableAction() + public function tableAction(): JsonResponse { $table = $this->getFactory() ->createProcessesTable(); diff --git a/src/SprykerMiddleware/Zed/Report/Communication/Controller/ResultController.php b/src/SprykerMiddleware/Zed/Report/Communication/Controller/ResultController.php index 074883b..50630dc 100644 --- a/src/SprykerMiddleware/Zed/Report/Communication/Controller/ResultController.php +++ b/src/SprykerMiddleware/Zed/Report/Communication/Controller/ResultController.php @@ -18,39 +18,14 @@ class ResultController extends AbstractController * * @return array */ - public function indexAction(Request $request) + public function indexAction(Request $request): array { $idResult = $this->castId($request->query->get(static::URL_PARAM_ID_RESULT)); - $processResult = $this->getFacade()->findProcessResultByResultId($idResult); - $attributes = []; - $attributes['Start Time'] = $processResult->getStartTime(); - $attributes['End Time'] = $processResult->getEndTime(); - $attributes['Item Count'] = $processResult->getItemCount(); - $attributes['Processed Item Count'] = $processResult->getProcessedItemCount(); - $attributes['Skipped Item Count'] = $processResult->getSkippedItemCount(); - $attributes['Failed Item Count'] = $processResult->getFailedItemCount(); - - $stageResultsTransfer = $processResult->getStageResults(); - - $stageResults = []; - - /** @var \Orm\Zed\Report\Persistence\SpyProcessResult $item */ - foreach ($stageResultsTransfer as $stageResult) { - $stageResults[] = [ - 'stage_name' => $stageResult->getStageName(), - 'input_item_count' => $stageResult->getInputItemCount(), - 'output_item_count' => $stageResult->getOutputItemCount(), - 'total_execution_time' => gmdate("H:i:s", round($stageResult->getTotalExecutionTime() * 0.0001)) . ' (H:i:s)', - 'average_time_per_item' => gmdate("H:i:s", round(($stageResult->getTotalExecutionTime() / $stageResult->getInputItemCount() * 0.0001))) . ' (H:i:s)', - ]; - } - + $processResult->getStageResults()[0]->getTotalExecutionTime(); return $this->viewResponse([ - 'processResultAttributes' => $attributes, - 'processConfiguration' => $processResult->getProcessConfiguration()->toArray(), - 'stageResults' => $stageResults, + 'processResult' => $processResult, ]); } } diff --git a/src/SprykerMiddleware/Zed/Report/Communication/ReportCommunicationFactory.php b/src/SprykerMiddleware/Zed/Report/Communication/ReportCommunicationFactory.php index 0802947..acbc96b 100644 --- a/src/SprykerMiddleware/Zed/Report/Communication/ReportCommunicationFactory.php +++ b/src/SprykerMiddleware/Zed/Report/Communication/ReportCommunicationFactory.php @@ -12,7 +12,7 @@ class ReportCommunicationFactory extends AbstractCommunicationFactory { /** - * @return \SprykerMiddleware\Zed\Report\Communication\Table\ProcessesTable|\Spryker\Zed\Gui\Communication\Table\AbstractTable + * @return \SprykerMiddleware\Zed\Report\Communication\Table\ProcessesTable */ public function createProcessesTable(): ProcessesTable { @@ -39,6 +39,9 @@ protected function getPropelProcessQuery(): SpyProcessQuery return $this->getProvidedDependency(ReportDependencyProvider::PROPEL_PROCESS_QUERY); } + /** + * @return \Orm\Zed\Report\Persistence\SpyProcessResultQuery + */ protected function getPropelProcessResultQuery(): SpyProcessResultQuery { return $this->getProvidedDependency(ReportDependencyProvider::PROPEL_PROCESS_RESULT_QUERY); diff --git a/src/SprykerMiddleware/Zed/Report/Communication/Table/ProcessResultsTable.php b/src/SprykerMiddleware/Zed/Report/Communication/Table/ProcessResultsTable.php index ba1beed..7e24c38 100644 --- a/src/SprykerMiddleware/Zed/Report/Communication/Table/ProcessResultsTable.php +++ b/src/SprykerMiddleware/Zed/Report/Communication/Table/ProcessResultsTable.php @@ -25,12 +25,21 @@ class ProcessResultsTable extends AbstractTable const URL_PARAM_ID_RESULT = 'id_result'; /** - * @var \Orm\Zed\Report\Persistence\SpyProcessQuery + * @var \Orm\Zed\Report\Persistence\SpyProcessResultQuery */ protected $processResultQuery; + /** + * @var int + */ protected $idProcess; + /** + * ProcessResultsTable constructor. + * + * @param \Orm\Zed\Report\Persistence\SpyProcessResultQuery $processResultQuery + * @param int $idProcess + */ public function __construct(SpyProcessResultQuery $processResultQuery, int $idProcess) { $this->processResultQuery = $processResultQuery; @@ -42,7 +51,7 @@ public function __construct(SpyProcessResultQuery $processResultQuery, int $idPr * * @return \Spryker\Zed\Gui\Communication\Table\TableConfiguration */ - protected function configure(TableConfiguration $config) + protected function configure(TableConfiguration $config): TableConfiguration { $config->setHeader([ static::COL_ID_PROCESS_RESULT => 'ID', @@ -77,7 +86,7 @@ protected function configure(TableConfiguration $config) * * @return array */ - protected function prepareData(TableConfiguration $config) + protected function prepareData(TableConfiguration $config): array { $query = $this->prepareQuery(); @@ -99,19 +108,20 @@ protected function prepareData(TableConfiguration $config) return $results; } - protected function prepareQuery() + /** + * @return \Orm\Zed\Report\Persistence\SpyProcessResultQuery + */ + protected function prepareQuery(): SpyProcessResultQuery { - $query = $this->processResultQuery->filterByFkProcessId($this->idProcess); - - return $query; + return $this->processResultQuery->filterByFkProcessId($this->idProcess); } /** - * @param array $item + * @param \Orm\Zed\Report\Persistence\SpyProcessResult $item * * @return string */ - protected function getActionButtons(SpyProcessResult $item) + protected function getActionButtons(SpyProcessResult $item): string { $buttons = []; $buttons[] = $this->createViewButton($item); @@ -122,9 +132,9 @@ protected function getActionButtons(SpyProcessResult $item) /** * @param \Orm\Zed\Report\Persistence\SpyProcessResult $item * - * @return \DateTime|string + * @return string */ - protected function getDuration(SpyProcessResult $item) + protected function getDuration(SpyProcessResult $item): string { if ($item->getEndTime('U') === null) { return $item->getCreatedAt('U') - $item->getStartTime('U'); @@ -137,7 +147,7 @@ protected function getDuration(SpyProcessResult $item) * * @return string */ - protected function getStatus(SpyProcessResult $item) + protected function getStatus(SpyProcessResult $item): string { if ($item->getFailedItemCount() > 0) { return 'Failed'; @@ -151,19 +161,19 @@ protected function getStatus(SpyProcessResult $item) } /** - * @param array $item + * @param \Orm\Zed\Report\Persistence\SpyProcessResult $item * * @return string */ - protected function createViewButton(SpyProcessResult $item) + protected function createViewButton(SpyProcessResult $item): string { - $viewDiscountUrl = Url::generate( + $viewButton = Url::generate( '/report/result/index', [ static::URL_PARAM_ID_RESULT => $item->getIdProcessResult(), ] ); - return $this->generateViewButton($viewDiscountUrl, 'Details'); + return $this->generateViewButton($viewButton, 'Details'); } } diff --git a/src/SprykerMiddleware/Zed/Report/Communication/Table/ProcessesTable.php b/src/SprykerMiddleware/Zed/Report/Communication/Table/ProcessesTable.php index 04b9ae9..33f6a08 100644 --- a/src/SprykerMiddleware/Zed/Report/Communication/Table/ProcessesTable.php +++ b/src/SprykerMiddleware/Zed/Report/Communication/Table/ProcessesTable.php @@ -33,7 +33,7 @@ public function __construct(SpyProcessQuery $processQuery) * * @return \Spryker\Zed\Gui\Communication\Table\TableConfiguration */ - protected function configure(TableConfiguration $config) + protected function configure(TableConfiguration $config): TableConfiguration { $config->setHeader([ static::COL_ID_PROCESS => 'ID', @@ -58,7 +58,7 @@ protected function configure(TableConfiguration $config) * * @return array */ - protected function prepareData(TableConfiguration $config) + protected function prepareData(TableConfiguration $config): array { $queryResults = $this->runQuery($this->processQuery, $config); $results = []; @@ -79,7 +79,7 @@ protected function prepareData(TableConfiguration $config) * * @return string */ - protected function getActionButtons(array $item) + protected function getActionButtons(array $item): string { $buttons = []; $buttons[] = $this->createViewButton($item); @@ -92,7 +92,7 @@ protected function getActionButtons(array $item) * * @return string */ - protected function createViewButton(array $item) + protected function createViewButton(array $item): string { $viewDiscountUrl = Url::generate( '/report/process/index', diff --git a/src/SprykerMiddleware/Zed/Report/Communication/navigation.xml b/src/SprykerMiddleware/Zed/Report/Communication/navigation.xml index 1ba191e..7c09cde 100644 --- a/src/SprykerMiddleware/Zed/Report/Communication/navigation.xml +++ b/src/SprykerMiddleware/Zed/Report/Communication/navigation.xml @@ -17,17 +17,15 @@ process index 0 - -
- - Result Details - report - result - index - 0 -
-
+
+ + Result Details + report + result + index + 0 +
diff --git a/src/SprykerMiddleware/Zed/Report/Dependency/Service/ReportToUtilEncodingBridge.php b/src/SprykerMiddleware/Zed/Report/Dependency/Service/ReportToUtilEncodingBridge.php index d2496c9..720060b 100644 --- a/src/SprykerMiddleware/Zed/Report/Dependency/Service/ReportToUtilEncodingBridge.php +++ b/src/SprykerMiddleware/Zed/Report/Dependency/Service/ReportToUtilEncodingBridge.php @@ -25,7 +25,7 @@ public function __construct($utilEncodingService) * * @return string */ - public function encodeJson($value, $options = null, $depth = null) + public function encodeJson($value, $options = null, $depth = null): string { return $this->utilEncodingService->encodeJson($value, $options, $depth); } @@ -38,7 +38,7 @@ public function encodeJson($value, $options = null, $depth = null) * * @return array */ - public function decodeJson($jsonValue, $assoc = false, $depth = null, $options = null) + public function decodeJson($jsonValue, $assoc = false, $depth = null, $options = null): array { return $this->utilEncodingService->decodeJson($jsonValue, $assoc, $depth, $options); } diff --git a/src/SprykerMiddleware/Zed/Report/Dependency/Service/ReportToUtilEncodingInterface.php b/src/SprykerMiddleware/Zed/Report/Dependency/Service/ReportToUtilEncodingInterface.php index 6a3ad32..278a098 100644 --- a/src/SprykerMiddleware/Zed/Report/Dependency/Service/ReportToUtilEncodingInterface.php +++ b/src/SprykerMiddleware/Zed/Report/Dependency/Service/ReportToUtilEncodingInterface.php @@ -11,7 +11,7 @@ interface ReportToUtilEncodingInterface * * @return string */ - public function encodeJson($value, $options = null, $depth = null); + public function encodeJson($value, $options = null, $depth = null): string; /** * @param string $jsonValue @@ -21,5 +21,5 @@ public function encodeJson($value, $options = null, $depth = null); * * @return array */ - public function decodeJson($jsonValue, $assoc = false, $depth = null, $options = null); + public function decodeJson($jsonValue, $assoc = false, $depth = null, $options = null): array; } diff --git a/src/SprykerMiddleware/Zed/Report/Persistence/Mapper/ProcessResultMapper.php b/src/SprykerMiddleware/Zed/Report/Persistence/Mapper/ProcessResultMapper.php index f6d0651..3171895 100644 --- a/src/SprykerMiddleware/Zed/Report/Persistence/Mapper/ProcessResultMapper.php +++ b/src/SprykerMiddleware/Zed/Report/Persistence/Mapper/ProcessResultMapper.php @@ -11,6 +11,9 @@ class ProcessResultMapper { + /** + * @var \SprykerMiddleware\Zed\Report\Dependency\Service\ReportToUtilEncodingInterface + */ protected $utilEncoding; /** @@ -59,8 +62,7 @@ public function mapEntityTransferToProcessResultTransfer(SpyProcessResultEntityT $processResultTransfer->setStartTime($processResultEntityTransfer->getStartTime()); $processResultTransfer->setEndTime($processResultEntityTransfer->getEndTime()); - $stages = $this->mapArrayToStagesResult($this->utilEncoding->decodeJson($processResultEntityTransfer->getStageResults(), true)); - $processResultTransfer->setStageResults($stages); + $processResultTransfer = $this->mapArrayToStagesResult($processResultTransfer, $this->utilEncoding->decodeJson($processResultEntityTransfer->getStageResults(), true)); $conf = new ProcessConfigurationTransfer(); $conf->fromArray($this->utilEncoding->decodeJson($processResultEntityTransfer->getProcessConfiguration(), true)); @@ -74,7 +76,7 @@ public function mapEntityTransferToProcessResultTransfer(SpyProcessResultEntityT * * @return array */ - public function mapStagesResultToArray(ArrayObject $stagesResults) + public function mapStagesResultToArray(ArrayObject $stagesResults): array { $stagesResultsArray = []; @@ -85,20 +87,20 @@ public function mapStagesResultToArray(ArrayObject $stagesResults) } /** + * @param \Generated\Shared\Transfer\ProcessResultTransfer $processResultTransfer * @param array $stagesResults * - * @return \ArrayObject + * @return \Generated\Shared\Transfer\ProcessResultTransfer */ - public function mapArrayToStagesResult(array $stagesResults) + public function mapArrayToStagesResult(ProcessResultTransfer $processResultTransfer, array $stagesResults): ProcessResultTransfer { - $res = new ArrayObject(); foreach ($stagesResults as $stage) { $stagesResultsTransfer = new StageResultsTransfer(); $stagesResultsTransfer->fromArray($stage); - $res->append($stagesResultsTransfer); + $processResultTransfer->addStageResult($stagesResultsTransfer); } - return $res; + return $processResultTransfer; } } diff --git a/src/SprykerMiddleware/Zed/Report/Persistence/ReportEntityManager.php b/src/SprykerMiddleware/Zed/Report/Persistence/ReportEntityManager.php index 2c0214b..4cca9ff 100644 --- a/src/SprykerMiddleware/Zed/Report/Persistence/ReportEntityManager.php +++ b/src/SprykerMiddleware/Zed/Report/Persistence/ReportEntityManager.php @@ -15,9 +15,9 @@ class ReportEntityManager extends AbstractEntityManager implements ReportEntityM /** * @param \Generated\Shared\Transfer\SpyProcessEntityTransfer $spyProcessEntityTransfer * - * @return mixed + * @return \Generated\Shared\Transfer\SpyProcessEntityTransfer */ - public function saveProcess(SpyProcessEntityTransfer $spyProcessEntityTransfer) + public function saveProcess(SpyProcessEntityTransfer $spyProcessEntityTransfer): SpyProcessEntityTransfer { $spyProcess = $this->getFactory() ->createProcessQuery() diff --git a/src/SprykerMiddleware/Zed/Report/Persistence/ReportEntityManagerInterface.php b/src/SprykerMiddleware/Zed/Report/Persistence/ReportEntityManagerInterface.php index 9b3cf20..36d6f4d 100644 --- a/src/SprykerMiddleware/Zed/Report/Persistence/ReportEntityManagerInterface.php +++ b/src/SprykerMiddleware/Zed/Report/Persistence/ReportEntityManagerInterface.php @@ -8,17 +8,17 @@ interface ReportEntityManagerInterface { /** - * @param \Generated\Shared\Transfer\SpyProcessEntityTransfer $processEntityTransfer + * @param \Generated\Shared\Transfer\SpyProcessEntityTransfer $spyProcessEntityTransfer * - * @return mixed + * @return \Generated\Shared\Transfer\SpyProcessEntityTransfer */ - public function saveProcess(SpyProcessEntityTransfer $processEntityTransfer); + public function saveProcess(SpyProcessEntityTransfer $spyProcessEntityTransfer): SpyProcessEntityTransfer; /** - * @param \Generated\Shared\Transfer\ProcessResultTransfer + * @param \Generated\Shared\Transfer\ProcessResultTransfer $processResultTransfer * @param \Generated\Shared\Transfer\SpyProcessEntityTransfer $spyProcessEntityTransfer * - * @return mixed + * @return \Generated\Shared\Transfer\ProcessResultTransfer */ - public function saveProcessResult(ProcessResultTransfer $processResultTransfer, SpyProcessEntityTransfer $spyProcessEntityTransfer); + public function saveProcessResult(ProcessResultTransfer $processResultTransfer, SpyProcessEntityTransfer $spyProcessEntityTransfer): ProcessResultTransfer; } diff --git a/src/SprykerMiddleware/Zed/Report/Persistence/ReportPersistenceFactory.php b/src/SprykerMiddleware/Zed/Report/Persistence/ReportPersistenceFactory.php index 5c78a9d..2a3de0c 100644 --- a/src/SprykerMiddleware/Zed/Report/Persistence/ReportPersistenceFactory.php +++ b/src/SprykerMiddleware/Zed/Report/Persistence/ReportPersistenceFactory.php @@ -5,6 +5,7 @@ use Orm\Zed\Report\Persistence\SpyProcessQuery; use Orm\Zed\Report\Persistence\SpyProcessResultQuery; use Spryker\Zed\Kernel\Persistence\AbstractPersistenceFactory; +use SprykerMiddleware\Zed\Report\Dependency\Service\ReportToUtilEncodingInterface; use SprykerMiddleware\Zed\Report\Persistence\Mapper\ProcessResultMapper; use SprykerMiddleware\Zed\Report\ReportDependencyProvider; @@ -15,7 +16,7 @@ class ReportPersistenceFactory extends AbstractPersistenceFactory */ public function createProcessQuery(): SpyProcessQuery { - return SpyProcessQuery::create(); + return $this->getProvidedDependency(ReportDependencyProvider::PROPEL_PROCESS_QUERY); } /** @@ -23,10 +24,13 @@ public function createProcessQuery(): SpyProcessQuery */ public function createProcessResultQuery(): SpyProcessResultQuery { - return SpyProcessResultQuery::create(); + return $this->getProvidedDependency(ReportDependencyProvider::PROPEL_PROCESS_RESULT_QUERY); } - public function createProcessResultMapper() + /** + * @return \SprykerMiddleware\Zed\Report\Persistence\Mapper\ProcessResultMapper + */ + public function createProcessResultMapper(): ProcessResultMapper { return new ProcessResultMapper($this->getUtilEncodingService()); } @@ -34,7 +38,7 @@ public function createProcessResultMapper() /** * @return \SprykerMiddleware\Zed\Report\Dependency\Service\ReportToUtilEncodingInterface */ - public function getUtilEncodingService() + public function getUtilEncodingService(): ReportToUtilEncodingInterface { return $this->getProvidedDependency(ReportDependencyProvider::SERVICE_UTIL_ENCODING); } diff --git a/src/SprykerMiddleware/Zed/Report/Persistence/ReportRepository.php b/src/SprykerMiddleware/Zed/Report/Persistence/ReportRepository.php index 30f18f5..8dc2b3f 100644 --- a/src/SprykerMiddleware/Zed/Report/Persistence/ReportRepository.php +++ b/src/SprykerMiddleware/Zed/Report/Persistence/ReportRepository.php @@ -2,6 +2,8 @@ namespace SprykerMiddleware\Zed\Report\Persistence; +use Generated\Shared\Transfer\ProcessResultTransfer; +use Generated\Shared\Transfer\SpyProcessEntityTransfer; use Spryker\Zed\Kernel\Persistence\AbstractRepository; /** @@ -14,7 +16,7 @@ class ReportRepository extends AbstractRepository implements ReportRepositoryInt * * @return \Generated\Shared\Transfer\ProcessResultTransfer|null */ - public function findProcessResultByResultId(int $idResult) + public function findProcessResultByResultId(int $idResult): ProcessResultTransfer { $query = $this->getFactory() ->createProcessResultQuery() @@ -34,9 +36,9 @@ public function findProcessResultByResultId(int $idResult) /** * @param int $idProcess * - * @return mixed + * @return \Generated\Shared\Transfer\SpyProcessEntityTransfer */ - public function findProcessByProcessId(int $idProcess) + public function findProcessByProcessId(int $idProcess): SpyProcessEntityTransfer { $query = $this->getFactory()->createProcessQuery()->filterByIdProcess($idProcess); return $this->buildQueryFromCriteria($query)->findOne(); diff --git a/src/SprykerMiddleware/Zed/Report/Persistence/ReportRepositoryInterface.php b/src/SprykerMiddleware/Zed/Report/Persistence/ReportRepositoryInterface.php index 4a805ba..d200f1e 100644 --- a/src/SprykerMiddleware/Zed/Report/Persistence/ReportRepositoryInterface.php +++ b/src/SprykerMiddleware/Zed/Report/Persistence/ReportRepositoryInterface.php @@ -2,19 +2,22 @@ namespace SprykerMiddleware\Zed\Report\Persistence; +use Generated\Shared\Transfer\ProcessResultTransfer; +use Generated\Shared\Transfer\SpyProcessEntityTransfer; + interface ReportRepositoryInterface { /** * @param int $idResult * - * @return mixed + * @return \Generated\Shared\Transfer\ProcessResultTransfer */ - public function findProcessResultByResultId(int $idResult); + public function findProcessResultByResultId(int $idResult): ProcessResultTransfer; /** * @param int $idProcess * - * @return mixed + * @return \Generated\Shared\Transfer\SpyProcessEntityTransfer */ - public function findProcessByProcessId(int $idProcess); + public function findProcessByProcessId(int $idProcess): SpyProcessEntityTransfer; } diff --git a/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig b/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig index 1845967..ed2e6a5 100644 --- a/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig +++ b/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig @@ -7,37 +7,88 @@ {% block widget_content %}

{{ 'Process Details' | trans }}

- {% for key, item in processResultAttributes %} - - - - - {% endfor %} + + + + + + + + + + + + + + + + + + + + + + + +
{{ key }} - {{ item | replace({".000000": ""}) }} -
Start Time{{ processResult.getStartTime | replace({".000000": ""}) }}
End Time{{ processResult.getEndTime | replace({".000000": ""}) }}
Items Count{{ processResult.getItemCount }}
Processed Item Count{{ processResult.getProcessedItemCount }}
Skipped Item Count{{ processResult.getSkippedItemCount }}
Failed Item Count{{ processResult.getFailedItemCount }}

{{ 'Process Configuration' | trans }}

- {% for key, item in processConfiguration %} - - - - - {% endfor %} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{{ key | replace({'_': " "}) | title }} - {% if item is iterable %} - - {% for k, value in item %} - - - - - {% endfor %} -
{{ k | replace({'_': " "}) | title }}{{ value }}
- {% else %} - {{ item }} - {% endif %} -
PluginNamePath
Iterator Plugin{{ processResult.getProcessConfiguration.getIteratorPluginName | raw }}
Input Stream Plugin{{ processResult.getProcessConfiguration.getInputStreamPlugin.getStreamPluginName | raw }}{{ processResult.getProcessConfiguration.getInputStreamPlugin.getPath | raw }}
Output Stream Plugin{{ processResult.getProcessConfiguration.getOutputStreamPlugin.getStreamPluginName | raw }}{{ processResult.getProcessConfiguration.getOutputStreamPlugin.getPath | raw }}
Logger Plugin{{ processResult.getProcessConfiguration.loggerPluginName | raw }}
Stage Plugins + {% for pluginName in processResult.getProcessConfiguration.stagePluginNames %} + {{ pluginName | raw }}
+ {% endfor %} +
Pre Process Hook Plugins + {% for pluginName in processResult.getProcessConfiguration.preProcessHookPluginNames %} + {{ pluginName | raw }}
+ {% endfor %} +
Post Process Hook Plugins + {% for pluginName in processResult.getProcessConfiguration.postProcessHookPluginNames %} + {{ pluginName | raw }}
+ {% endfor %} +

{{ 'Process Stage Results' | trans }}

@@ -51,17 +102,18 @@ Average Item Execution Time - {% for item in stageResults %} + {% for item in processResult.getStageResults %} - {{ item.stage_name }} - {{ item.input_item_count }} - {{ item.output_item_count }} - {{ item.total_execution_time }} - {{ item.average_time_per_item }} + {{ item.getStageName }} + {{ item.getInputItemCount }} + {{ item.getOutputItemCount }} + {{ (item.getTotalExecutionTime * 0.0001) | round | date('H:i:s') }} + {{ (item.getTotalExecutionTime/item.getInputItemCount * 0.0001) | round |date('H:i:s') }} {% endfor %} + {% endblock %} {% endembed %} diff --git a/src/SprykerMiddleware/Zed/Report/ReportDependencyProvider.php b/src/SprykerMiddleware/Zed/Report/ReportDependencyProvider.php index 78739c9..d28f420 100644 --- a/src/SprykerMiddleware/Zed/Report/ReportDependencyProvider.php +++ b/src/SprykerMiddleware/Zed/Report/ReportDependencyProvider.php @@ -37,7 +37,7 @@ public function provideCommunicationLayerDependencies(Container $container): Con */ protected function addPropelProcessQuery(Container $container): Container { - $container[static::PROPEL_PROCESS_QUERY] = function (Container $container) { + $container[static::PROPEL_PROCESS_QUERY] = function (Container $container): SpyProcessQuery { return SpyProcessQuery::create(); }; @@ -51,7 +51,7 @@ protected function addPropelProcessQuery(Container $container): Container */ protected function addPropelProcessResultQuery(Container $container): Container { - $container[static::PROPEL_PROCESS_RESULT_QUERY] = function (Container $container) { + $container[static::PROPEL_PROCESS_RESULT_QUERY] = function (Container $container): SpyProcessResultQuery { return SpyProcessResultQuery::create(); }; @@ -63,9 +63,9 @@ protected function addPropelProcessResultQuery(Container $container): Container * * @return \Spryker\Zed\Kernel\Container */ - protected function addServiceUtilEncoding(Container $container) + protected function addServiceUtilEncoding(Container $container): Container { - $container[static::SERVICE_UTIL_ENCODING] = function (Container $container) { + $container[static::SERVICE_UTIL_ENCODING] = function (Container $container): ReportToUtilEncodingBridge { return new ReportToUtilEncodingBridge( $container->getLocator()->utilEncoding()->service() ); @@ -79,9 +79,11 @@ protected function addServiceUtilEncoding(Container $container) * * @return \Spryker\Zed\Kernel\Container */ - public function providePersistenceLayerDependencies(Container $container) + public function providePersistenceLayerDependencies(Container $container): Container { $container = $this->addServiceUtilEncoding($container); + $container = $this->addPropelProcessQuery($container); + $container = $this->addPropelProcessResultQuery($container); return $container; } From 3ccf3ccb1cbef0f05ebbe2e11beaabf3cb9aa9a4 Mon Sep 17 00:00:00 2001 From: Oleh Okhremchuk Date: Mon, 26 Mar 2018 12:58:10 +0300 Subject: [PATCH 04/25] SM-14: Factory style fixes --- .../Zed/Report/Business/ReportBusinessFactory.php | 5 +++-- .../Report/Communication/ReportCommunicationFactory.php | 9 +++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/SprykerMiddleware/Zed/Report/Business/ReportBusinessFactory.php b/src/SprykerMiddleware/Zed/Report/Business/ReportBusinessFactory.php index 2c1844d..7787a08 100644 --- a/src/SprykerMiddleware/Zed/Report/Business/ReportBusinessFactory.php +++ b/src/SprykerMiddleware/Zed/Report/Business/ReportBusinessFactory.php @@ -4,6 +4,7 @@ use Spryker\Zed\Kernel\Business\AbstractBusinessFactory; use SprykerMiddleware\Zed\Report\Business\Model\ProcessResult; +use SprykerMiddleware\Zed\Report\Business\Model\ProcessResultInterface; /** * @method \SprykerMiddleware\Zed\Report\Persistence\ReportRepositoryInterface getRepository() @@ -12,9 +13,9 @@ class ReportBusinessFactory extends AbstractBusinessFactory { /** - * @return \SprykerMiddleware\Zed\Report\Business\Model\ProcessResult + * @return \SprykerMiddleware\Zed\Report\Business\Model\ProcessResultInterface */ - public function createProcessResult(): ProcessResult + public function createProcessResult(): ProcessResultInterface { return new ProcessResult( $this->getRepository(), diff --git a/src/SprykerMiddleware/Zed/Report/Communication/ReportCommunicationFactory.php b/src/SprykerMiddleware/Zed/Report/Communication/ReportCommunicationFactory.php index acbc96b..9947c8b 100644 --- a/src/SprykerMiddleware/Zed/Report/Communication/ReportCommunicationFactory.php +++ b/src/SprykerMiddleware/Zed/Report/Communication/ReportCommunicationFactory.php @@ -4,6 +4,7 @@ use Orm\Zed\Report\Persistence\SpyProcessQuery; use Orm\Zed\Report\Persistence\SpyProcessResultQuery; +use Spryker\Zed\Gui\Communication\Table\AbstractTable; use Spryker\Zed\Kernel\Communication\AbstractCommunicationFactory; use SprykerMiddleware\Zed\Report\Communication\Table\ProcessesTable; use SprykerMiddleware\Zed\Report\Communication\Table\ProcessResultsTable; @@ -12,9 +13,9 @@ class ReportCommunicationFactory extends AbstractCommunicationFactory { /** - * @return \SprykerMiddleware\Zed\Report\Communication\Table\ProcessesTable + * @return \Spryker\Zed\Gui\Communication\Table\AbstractTable */ - public function createProcessesTable(): ProcessesTable + public function createProcessesTable(): AbstractTable { $processQuery = $this->getPropelProcessQuery(); return new ProcessesTable($processQuery); @@ -23,9 +24,9 @@ public function createProcessesTable(): ProcessesTable /** * @param int $idProcess * - * @return \SprykerMiddleware\Zed\Report\Communication\Table\ProcessResultsTable + * @return \Spryker\Zed\Gui\Communication\Table\AbstractTable */ - public function createProcessResultsTable(int $idProcess): ProcessResultsTable + public function createProcessResultsTable(int $idProcess): AbstractTable { $processResultQuery = $this->getPropelProcessResultQuery(); return new ProcessResultsTable($processResultQuery, $idProcess); From a3a77ebad2f4428ff509ad6ea8a2262f0b7d99fa Mon Sep 17 00:00:00 2001 From: Oleh Okhremchuk Date: Mon, 26 Mar 2018 14:04:54 +0300 Subject: [PATCH 05/25] SM-14: updated twig template to use correct property names --- .../Controller/ResultController.php | 1 - .../Communication/Table/ProcessesTable.php | 4 +- .../Zed/Report/Presentation/Result/index.twig | 42 +++++++++---------- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/SprykerMiddleware/Zed/Report/Communication/Controller/ResultController.php b/src/SprykerMiddleware/Zed/Report/Communication/Controller/ResultController.php index 50630dc..fecd1b7 100644 --- a/src/SprykerMiddleware/Zed/Report/Communication/Controller/ResultController.php +++ b/src/SprykerMiddleware/Zed/Report/Communication/Controller/ResultController.php @@ -23,7 +23,6 @@ public function indexAction(Request $request): array $idResult = $this->castId($request->query->get(static::URL_PARAM_ID_RESULT)); $processResult = $this->getFacade()->findProcessResultByResultId($idResult); - $processResult->getStageResults()[0]->getTotalExecutionTime(); return $this->viewResponse([ 'processResult' => $processResult, ]); diff --git a/src/SprykerMiddleware/Zed/Report/Communication/Table/ProcessesTable.php b/src/SprykerMiddleware/Zed/Report/Communication/Table/ProcessesTable.php index 33f6a08..a85db6b 100644 --- a/src/SprykerMiddleware/Zed/Report/Communication/Table/ProcessesTable.php +++ b/src/SprykerMiddleware/Zed/Report/Communication/Table/ProcessesTable.php @@ -94,13 +94,13 @@ protected function getActionButtons(array $item): string */ protected function createViewButton(array $item): string { - $viewDiscountUrl = Url::generate( + $viewButtonUrl = Url::generate( '/report/process/index', [ ProcessController::URL_PARAM_ID_PROCESS => $item[SpyProcessTableMap::COL_ID_PROCESS], ] ); - return $this->generateViewButton($viewDiscountUrl, 'View'); + return $this->generateViewButton($viewButtonUrl, 'View'); } } diff --git a/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig b/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig index ed2e6a5..e9fc084 100644 --- a/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig +++ b/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig @@ -9,27 +9,27 @@ - + - + - + - + - + - +
Start Time{{ processResult.getStartTime | replace({".000000": ""}) }}{{ processResult.StartTime | replace({".000000": ""}) }}
End Time{{ processResult.getEndTime | replace({".000000": ""}) }}{{ processResult.EndTime | replace({".000000": ""}) }}
Items Count{{ processResult.getItemCount }}{{ processResult.ItemCount }}
Processed Item Count{{ processResult.getProcessedItemCount }}{{ processResult.ProcessedItemCount }}
Skipped Item Count{{ processResult.getSkippedItemCount }}{{ processResult.SkippedItemCount }}
Failed Item Count{{ processResult.getFailedItemCount }}{{ processResult.FailedItemCount }}
@@ -44,28 +44,28 @@ Iterator Plugin - {{ processResult.getProcessConfiguration.getIteratorPluginName | raw }} + {{ processResult.ProcessConfiguration.IteratorPluginName | raw }} Input Stream Plugin - {{ processResult.getProcessConfiguration.getInputStreamPlugin.getStreamPluginName | raw }} - {{ processResult.getProcessConfiguration.getInputStreamPlugin.getPath | raw }} + {{ processResult.ProcessConfiguration.InputStreamPlugin.StreamPluginName | raw }} + {{ processResult.ProcessConfiguration.InputStreamPlugin.Path | raw }} Output Stream Plugin - {{ processResult.getProcessConfiguration.getOutputStreamPlugin.getStreamPluginName | raw }} - {{ processResult.getProcessConfiguration.getOutputStreamPlugin.getPath | raw }} + {{ processResult.ProcessConfiguration.OutputStreamPlugin.StreamPluginName | raw }} + {{ processResult.ProcessConfiguration.OutputStreamPlugin.Path | raw }} Logger Plugin - {{ processResult.getProcessConfiguration.loggerPluginName | raw }} + {{ processResult.ProcessConfiguration.loggerPluginName | raw }} Stage Plugins - {% for pluginName in processResult.getProcessConfiguration.stagePluginNames %} + {% for pluginName in processResult.ProcessConfiguration.stagePluginNames %} {{ pluginName | raw }}
{% endfor %} @@ -74,7 +74,7 @@ Pre Process Hook Plugins - {% for pluginName in processResult.getProcessConfiguration.preProcessHookPluginNames %} + {% for pluginName in processResult.ProcessConfiguration.preProcessHookPluginNames %} {{ pluginName | raw }}
{% endfor %} @@ -83,7 +83,7 @@ Post Process Hook Plugins - {% for pluginName in processResult.getProcessConfiguration.postProcessHookPluginNames %} + {% for pluginName in processResult.ProcessConfiguration.postProcessHookPluginNames %} {{ pluginName | raw }}
{% endfor %} @@ -102,13 +102,13 @@ Average Item Execution Time - {% for item in processResult.getStageResults %} + {% for item in processResult.StageResults %} - {{ item.getStageName }} - {{ item.getInputItemCount }} - {{ item.getOutputItemCount }} - {{ (item.getTotalExecutionTime * 0.0001) | round | date('H:i:s') }} - {{ (item.getTotalExecutionTime/item.getInputItemCount * 0.0001) | round |date('H:i:s') }} + {{ item.StageName }} + {{ item.InputItemCount }} + {{ item.OutputItemCount }} + {{ (item.TotalExecutionTime * 0.001) | round | date('H:i:s') }} + {{ (item.TotalExecutionTime/item.InputItemCount * 0.001) | round | date('H:i:s') }} {% endfor %} From fbcfba27c8aa9e1e08a3b3dea9b5ec38d4ebec85 Mon Sep 17 00:00:00 2001 From: Oleh Okhremchuk Date: Mon, 26 Mar 2018 14:35:32 +0300 Subject: [PATCH 06/25] SM-14: Updated ReportRepository PHPDoc comment --- .../Zed/Report/Persistence/ReportRepository.php | 4 ++-- .../Zed/Report/Persistence/ReportRepositoryInterface.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SprykerMiddleware/Zed/Report/Persistence/ReportRepository.php b/src/SprykerMiddleware/Zed/Report/Persistence/ReportRepository.php index 8dc2b3f..0083a4e 100644 --- a/src/SprykerMiddleware/Zed/Report/Persistence/ReportRepository.php +++ b/src/SprykerMiddleware/Zed/Report/Persistence/ReportRepository.php @@ -14,9 +14,9 @@ class ReportRepository extends AbstractRepository implements ReportRepositoryInt /** * @param int $idResult * - * @return \Generated\Shared\Transfer\ProcessResultTransfer|null + * @return \Generated\Shared\Transfer\ProcessResultTransfer */ - public function findProcessResultByResultId(int $idResult): ProcessResultTransfer + public function findProcessResultByResultId(int $idResult): ?ProcessResultTransfer { $query = $this->getFactory() ->createProcessResultQuery() diff --git a/src/SprykerMiddleware/Zed/Report/Persistence/ReportRepositoryInterface.php b/src/SprykerMiddleware/Zed/Report/Persistence/ReportRepositoryInterface.php index d200f1e..3989167 100644 --- a/src/SprykerMiddleware/Zed/Report/Persistence/ReportRepositoryInterface.php +++ b/src/SprykerMiddleware/Zed/Report/Persistence/ReportRepositoryInterface.php @@ -12,7 +12,7 @@ interface ReportRepositoryInterface * * @return \Generated\Shared\Transfer\ProcessResultTransfer */ - public function findProcessResultByResultId(int $idResult): ProcessResultTransfer; + public function findProcessResultByResultId(int $idResult): ?ProcessResultTransfer; /** * @param int $idProcess From a62e7b2918207c28dfa1abf272a89e1d933d38be Mon Sep 17 00:00:00 2001 From: Oleh Okhremchuk Date: Mon, 26 Mar 2018 14:45:53 +0300 Subject: [PATCH 07/25] SM-14 : Updated twig property names --- .../Zed/Report/Presentation/Result/index.twig | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig b/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig index e9fc084..72fce56 100644 --- a/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig +++ b/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig @@ -9,27 +9,27 @@ - + - + - + - + - + - +
Start Time{{ processResult.StartTime | replace({".000000": ""}) }}{{ processResult.startTime | replace({".000000": ""}) }}
End Time{{ processResult.EndTime | replace({".000000": ""}) }}{{ processResult.endTime | replace({".000000": ""}) }}
Items Count{{ processResult.ItemCount }}{{ processResult.itemCount }}
Processed Item Count{{ processResult.ProcessedItemCount }}{{ processResult.processedItemCount }}
Skipped Item Count{{ processResult.SkippedItemCount }}{{ processResult.skippedItemCount }}
Failed Item Count{{ processResult.FailedItemCount }}{{ processResult.failedItemCount }}
@@ -44,28 +44,28 @@ Iterator Plugin - {{ processResult.ProcessConfiguration.IteratorPluginName | raw }} + {{ processResult.processConfiguration.iteratorPluginName | raw }} Input Stream Plugin - {{ processResult.ProcessConfiguration.InputStreamPlugin.StreamPluginName | raw }} - {{ processResult.ProcessConfiguration.InputStreamPlugin.Path | raw }} + {{ processResult.processConfiguration.inputStreamPlugin.streamPluginName | raw }} + {{ processResult.processConfiguration.inputStreamPlugin.path | raw }} Output Stream Plugin - {{ processResult.ProcessConfiguration.OutputStreamPlugin.StreamPluginName | raw }} - {{ processResult.ProcessConfiguration.OutputStreamPlugin.Path | raw }} + {{ processResult.processConfiguration.outputStreamPlugin.streamPluginName | raw }} + {{ processResult.processConfiguration.outputStreamPlugin.path | raw }} Logger Plugin - {{ processResult.ProcessConfiguration.loggerPluginName | raw }} + {{ processResult.processConfiguration.loggerPluginName | raw }} Stage Plugins - {% for pluginName in processResult.ProcessConfiguration.stagePluginNames %} + {% for pluginName in processResult.processConfiguration.stagePluginNames %} {{ pluginName | raw }}
{% endfor %} @@ -74,7 +74,7 @@ Pre Process Hook Plugins - {% for pluginName in processResult.ProcessConfiguration.preProcessHookPluginNames %} + {% for pluginName in processResult.processConfiguration.preProcessHookPluginNames %} {{ pluginName | raw }}
{% endfor %} @@ -83,7 +83,7 @@ Post Process Hook Plugins - {% for pluginName in processResult.ProcessConfiguration.postProcessHookPluginNames %} + {% for pluginName in processResult.processConfiguration.postProcessHookPluginNames %} {{ pluginName | raw }}
{% endfor %} @@ -102,13 +102,13 @@ Average Item Execution Time - {% for item in processResult.StageResults %} + {% for item in processResult.stageResults %} - {{ item.StageName }} - {{ item.InputItemCount }} - {{ item.OutputItemCount }} - {{ (item.TotalExecutionTime * 0.001) | round | date('H:i:s') }} - {{ (item.TotalExecutionTime/item.InputItemCount * 0.001) | round | date('H:i:s') }} + {{ item.stageName }} + {{ item.inputItemCount }} + {{ item.outputItemCount }} + {{ (item.totalExecutionTime * 0.001) | round | date('H:i:s') }} + {{ (item.totalExecutionTime/item.inputItemCount * 0.001) | round | date('H:i:s') }} {% endfor %} From eb4e25155f1b6b95fb1554a0e8ca5276220f617d Mon Sep 17 00:00:00 2001 From: Oleh Okhremchuk Date: Thu, 29 Mar 2018 20:10:23 +0300 Subject: [PATCH 08/25] SM-137 : Updated time format for Total Execution Time and Average Item Execution Time --- .../Zed/Report/Presentation/Result/index.twig | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig b/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig index 72fce56..0513c7c 100644 --- a/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig +++ b/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig @@ -107,8 +107,9 @@ {{ item.stageName }} {{ item.inputItemCount }} {{ item.outputItemCount }} - {{ (item.totalExecutionTime * 0.001) | round | date('H:i:s') }} - {{ (item.totalExecutionTime/item.inputItemCount * 0.001) | round | date('H:i:s') }} + {{ (item.totalExecutionTime/1000) | round | date('H:i:s') }} + :{{ '%03d' | format(item.totalExecutionTime%1000) }} + {% if item.inputItemCount > 0 %}{{ (item.totalExecutionTime/item.inputItemCount/1000) | round | date('H:i:s') }}:{{ '%03d' | format((item.totalExecutionTime/item.inputItemCount)%1000) }}{% endif %} {% endfor %} From c0b58cb53402f5765f5e3aaa73825720677a95bc Mon Sep 17 00:00:00 2001 From: Oleh Okhremchuk Date: Thu, 29 Mar 2018 20:22:10 +0300 Subject: [PATCH 09/25] SM-139 : Added status label to report instad failed item couner --- .../Zed/Report/Presentation/Result/index.twig | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig b/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig index 72fce56..d99a2a8 100644 --- a/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig +++ b/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig @@ -28,8 +28,15 @@ {{ processResult.skippedItemCount }} - Failed Item Count - {{ processResult.failedItemCount }} + Process Status + {% if processResult.failedItemCount > 0 %} + Failed + {% elseif processResult.skippedItemCount > 0 %} + Were skipped items + {% else %} + Success + {% endif %} + From d3afe004c2969e7bb4b8e7568022b222e4120b91 Mon Sep 17 00:00:00 2001 From: Oleh Okhremchuk Date: Fri, 30 Mar 2018 19:24:42 +0300 Subject: [PATCH 10/25] SM-140 : Zed UI fixes --- .../Zed/Report/Business/Model/ProcessResult.php | 10 ++++++++++ .../Business/Model/ProcessResultInterface.php | 7 +++++++ .../Zed/Report/Business/ReportFacade.php | 12 ++++++++++++ .../Zed/Report/Business/ReportFacadeInterface.php | 7 +++++++ .../Communication/Controller/ResultController.php | 2 ++ .../Zed/Report/Persistence/ReportRepository.php | 15 +++++++++++++++ .../Persistence/ReportRepositoryInterface.php | 7 +++++++ .../Zed/Report/Presentation/Process/index.twig | 9 ++++++++- .../Zed/Report/Presentation/Report/index.twig | 2 ++ .../Zed/Report/Presentation/Result/index.twig | 10 ++++++++++ 10 files changed, 80 insertions(+), 1 deletion(-) diff --git a/src/SprykerMiddleware/Zed/Report/Business/Model/ProcessResult.php b/src/SprykerMiddleware/Zed/Report/Business/Model/ProcessResult.php index 6e25007..75bd08b 100644 --- a/src/SprykerMiddleware/Zed/Report/Business/Model/ProcessResult.php +++ b/src/SprykerMiddleware/Zed/Report/Business/Model/ProcessResult.php @@ -55,6 +55,16 @@ public function findProcessResultByResultId(int $idResult): ProcessResultTransfe return $this->reportRepository->findProcessResultByResultId($idResult); } + /** + * @param int $idResult + * + * @return \Generated\Shared\Transfer\SpyProcessEntityTransfer + */ + public function findProcessByIdResult(int $idResult): SpyProcessEntityTransfer + { + return $this->reportRepository->findProcessByIdResult($idResult); + } + /** * @param int $idProcess * diff --git a/src/SprykerMiddleware/Zed/Report/Business/Model/ProcessResultInterface.php b/src/SprykerMiddleware/Zed/Report/Business/Model/ProcessResultInterface.php index f555602..6690d5e 100644 --- a/src/SprykerMiddleware/Zed/Report/Business/Model/ProcessResultInterface.php +++ b/src/SprykerMiddleware/Zed/Report/Business/Model/ProcessResultInterface.php @@ -21,6 +21,13 @@ public function saveProcessResult(ProcessResultTransfer $processResultTransfer): */ public function findProcessResultByResultId(int $idResult): ProcessResultTransfer; + /** + * @param int $idResult + * + * @return \Generated\Shared\Transfer\SpyProcessEntityTransfer + */ + public function findProcessByIdResult(int $idResult): SpyProcessEntityTransfer; + /** * @param int $idProcess * diff --git a/src/SprykerMiddleware/Zed/Report/Business/ReportFacade.php b/src/SprykerMiddleware/Zed/Report/Business/ReportFacade.php index e83b692..9438ef1 100644 --- a/src/SprykerMiddleware/Zed/Report/Business/ReportFacade.php +++ b/src/SprykerMiddleware/Zed/Report/Business/ReportFacade.php @@ -35,6 +35,18 @@ public function findProcessResultByResultId(int $idResult): ProcessResultTransfe ->findProcessResultByResultId($idResult); } + /** + * @param int $idResult + * + * @return \Generated\Shared\Transfer\SpyProcessEntityTransfer + */ + public function findProcessByIdResult(int $idResult): SpyProcessEntityTransfer + { + return $this->getFactory() + ->createProcessResult() + ->findProcessByIdResult($idResult); + } + /** * @param int $idProcess * diff --git a/src/SprykerMiddleware/Zed/Report/Business/ReportFacadeInterface.php b/src/SprykerMiddleware/Zed/Report/Business/ReportFacadeInterface.php index d311d94..241f93a 100644 --- a/src/SprykerMiddleware/Zed/Report/Business/ReportFacadeInterface.php +++ b/src/SprykerMiddleware/Zed/Report/Business/ReportFacadeInterface.php @@ -21,6 +21,13 @@ public function saveProcessResult(ProcessResultTransfer $processResultTransfer): */ public function findProcessResultByResultId(int $idResult): ProcessResultTransfer; + /** + * @param int $idResult + * + * @return \Generated\Shared\Transfer\SpyProcessEntityTransfer + */ + public function findProcessByIdResult(int $idResult): SpyProcessEntityTransfer; + /** * @param int $idProcess * diff --git a/src/SprykerMiddleware/Zed/Report/Communication/Controller/ResultController.php b/src/SprykerMiddleware/Zed/Report/Communication/Controller/ResultController.php index fecd1b7..abf1a03 100644 --- a/src/SprykerMiddleware/Zed/Report/Communication/Controller/ResultController.php +++ b/src/SprykerMiddleware/Zed/Report/Communication/Controller/ResultController.php @@ -22,9 +22,11 @@ public function indexAction(Request $request): array { $idResult = $this->castId($request->query->get(static::URL_PARAM_ID_RESULT)); $processResult = $this->getFacade()->findProcessResultByResultId($idResult); + $process = $this->getFacade()->findProcessByIdResult($idResult); return $this->viewResponse([ 'processResult' => $processResult, + 'process' => $process, ]); } } diff --git a/src/SprykerMiddleware/Zed/Report/Persistence/ReportRepository.php b/src/SprykerMiddleware/Zed/Report/Persistence/ReportRepository.php index 0083a4e..99021a0 100644 --- a/src/SprykerMiddleware/Zed/Report/Persistence/ReportRepository.php +++ b/src/SprykerMiddleware/Zed/Report/Persistence/ReportRepository.php @@ -33,6 +33,21 @@ public function findProcessResultByResultId(int $idResult): ?ProcessResultTransf return null; } + /** + * @param int $idResult + * + * @return \Generated\Shared\Transfer\SpyProcessEntityTransfer + */ + public function findProcessByIdResult(int $idResult): SpyProcessEntityTransfer + { + $resultQuery = $this->getFactory() + ->createProcessResultQuery() + ->filterByIdProcessResult($idResult); + $processResult = $this->buildQueryFromCriteria($resultQuery)->findOne(); + $processId = $processResult->getFkProcessId(); + return $this->findProcessByProcessId($processId); + } + /** * @param int $idProcess * diff --git a/src/SprykerMiddleware/Zed/Report/Persistence/ReportRepositoryInterface.php b/src/SprykerMiddleware/Zed/Report/Persistence/ReportRepositoryInterface.php index 3989167..701b0c2 100644 --- a/src/SprykerMiddleware/Zed/Report/Persistence/ReportRepositoryInterface.php +++ b/src/SprykerMiddleware/Zed/Report/Persistence/ReportRepositoryInterface.php @@ -14,6 +14,13 @@ interface ReportRepositoryInterface */ public function findProcessResultByResultId(int $idResult): ?ProcessResultTransfer; + /** + * @param int $idResult + * + * @return \Generated\Shared\Transfer\SpyProcessEntityTransfer + */ + public function findProcessByIdResult(int $idResult): SpyProcessEntityTransfer; + /** * @param int $idProcess * diff --git a/src/SprykerMiddleware/Zed/Report/Presentation/Process/index.twig b/src/SprykerMiddleware/Zed/Report/Presentation/Process/index.twig index 7ae362e..01ab493 100644 --- a/src/SprykerMiddleware/Zed/Report/Presentation/Process/index.twig +++ b/src/SprykerMiddleware/Zed/Report/Presentation/Process/index.twig @@ -1,11 +1,18 @@ {% extends '@Gui/Layout/layout.twig' %} + +{% block section_title 'Overview Process Results' | trans %} + +{% block action %} + {{ backActionButton('/report/report', 'Back to Processes List' | trans) }} +{% endblock %} + {% block content %} {% embed '@Gui/Partials/widget.twig' with { widget_title: 'Process Results' | trans } %} {% block widget_content %} -

{{ 'Process' | trans }}

+

{{ process.processName }}

{% for key, item in process %} diff --git a/src/SprykerMiddleware/Zed/Report/Presentation/Report/index.twig b/src/SprykerMiddleware/Zed/Report/Presentation/Report/index.twig index f02d2db..68912a6 100644 --- a/src/SprykerMiddleware/Zed/Report/Presentation/Report/index.twig +++ b/src/SprykerMiddleware/Zed/Report/Presentation/Report/index.twig @@ -1,5 +1,7 @@ {% extends '@Gui/Layout/layout.twig' %} +{% block section_title 'Overview Processes' | trans %} + {% block content %} {% embed '@Gui/Partials/widget.twig' with { widget_title: 'Processes List' | trans } %} diff --git a/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig b/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig index 72fce56..474c145 100644 --- a/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig +++ b/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig @@ -1,4 +1,10 @@ {% extends '@Gui/Layout/layout.twig' %} +{% block section_title 'View Result Details' | trans %} + +{% block action %} + {{ backActionButton('/report/process/index?id_process=' ~ process.idProcess, 'Back to Process Results' | trans) }} +{% endblock %} + {% block content %} @@ -7,6 +13,10 @@ {% block widget_content %}

{{ 'Process Details' | trans }}

+ + + + From 64ad0749949561680aa030c1e36dfd8a5b1c0ac4 Mon Sep 17 00:00:00 2001 From: Oleh Okhremchuk Date: Mon, 2 Apr 2018 13:26:06 +0300 Subject: [PATCH 11/25] SM-140 : Added process duration field to the result view --- .../Zed/Report/Presentation/Result/index.twig | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig b/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig index 474c145..4fc4765 100644 --- a/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig +++ b/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig @@ -41,6 +41,13 @@ + + + {% set diffdate = (date( processResult.endTime|date("Y:m:d H:i:s") )).diff(date( processResult.startTime|date("Y:m:d H:i:s") )) %} + +
Process Name{{ process.processName }}
Start Time {{ processResult.startTime | replace({".000000": ""}) }}Failed Item Count {{ processResult.failedItemCount }}
Process Duration + {{ diffdate|date("%H:%i:%s")}} (H:i:s) +

{{ 'Process Configuration' | trans }}

From 6c2319882fc9d0d50b70e7648e984d6593edb5dd Mon Sep 17 00:00:00 2001 From: Oleh Okhremchuk Date: Mon, 2 Apr 2018 16:20:01 +0300 Subject: [PATCH 12/25] SM-137 : Updated format to H:i:s.u --- .../Zed/Report/Presentation/Result/index.twig | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig b/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig index 0513c7c..f9052ea 100644 --- a/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig +++ b/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig @@ -107,9 +107,8 @@ {{ item.stageName }} {{ item.inputItemCount }} {{ item.outputItemCount }} - {{ (item.totalExecutionTime/1000) | round | date('H:i:s') }} - :{{ '%03d' | format(item.totalExecutionTime%1000) }} - {% if item.inputItemCount > 0 %}{{ (item.totalExecutionTime/item.inputItemCount/1000) | round | date('H:i:s') }}:{{ '%03d' | format((item.totalExecutionTime/item.inputItemCount)%1000) }}{% endif %} + {{ (item.totalExecutionTime/1000) | round | date('H:i:s') }}.{{ '%03d' | format(item.totalExecutionTime%1000) }} + {% if item.inputItemCount > 0 %}{{ (item.totalExecutionTime/item.inputItemCount/1000) | round | date('H:i:s') }}.{{ '%03d' | format((item.totalExecutionTime/item.inputItemCount)%1000) }}{% endif %} {% endfor %} From f686e4a66a2095dca0c3dffb1ecda34167083ad1 Mon Sep 17 00:00:00 2001 From: Oleh Okhremchuk Date: Mon, 2 Apr 2018 16:23:39 +0300 Subject: [PATCH 13/25] SM-139 : Updated label spelling failed to fail --- .../Zed/Report/Communication/Table/ProcessResultsTable.php | 2 +- src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SprykerMiddleware/Zed/Report/Communication/Table/ProcessResultsTable.php b/src/SprykerMiddleware/Zed/Report/Communication/Table/ProcessResultsTable.php index 7e24c38..467f4a0 100644 --- a/src/SprykerMiddleware/Zed/Report/Communication/Table/ProcessResultsTable.php +++ b/src/SprykerMiddleware/Zed/Report/Communication/Table/ProcessResultsTable.php @@ -150,7 +150,7 @@ protected function getDuration(SpyProcessResult $item): string protected function getStatus(SpyProcessResult $item): string { if ($item->getFailedItemCount() > 0) { - return 'Failed'; + return 'Fail'; } if ($item->getSkippedItemCount() > 0) { diff --git a/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig b/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig index d99a2a8..1eaa2b9 100644 --- a/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig +++ b/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig @@ -30,7 +30,7 @@ Process Status {% if processResult.failedItemCount > 0 %} - Failed + Fail {% elseif processResult.skippedItemCount > 0 %} Were skipped items {% else %} From eb3a8cdac0128839acd7f16dae6fe81cf669960a Mon Sep 17 00:00:00 2001 From: vhrychenko Date: Thu, 5 Apr 2018 17:46:05 +0300 Subject: [PATCH 14/25] SM-143 Fix date format --- src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig b/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig index f63e7fe..a0852b1 100644 --- a/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig +++ b/src/SprykerMiddleware/Zed/Report/Presentation/Result/index.twig @@ -52,7 +52,7 @@ Process Duration {% set diffdate = (date( processResult.endTime|date("Y:m:d H:i:s") )).diff(date( processResult.startTime|date("Y:m:d H:i:s") )) %} - {{ diffdate|date("%H:%i:%s")}} (H:i:s) + {{ diffdate|date("%H:%I:%S")}} (H:i:s) From 339076598dfa842e04752fea0efecc2aa400698e Mon Sep 17 00:00:00 2001 From: vhrychenko Date: Fri, 6 Apr 2018 10:42:05 +0300 Subject: [PATCH 15/25] SM-143 Fix date format for table --- .../Zed/Report/Communication/Table/ProcessResultsTable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SprykerMiddleware/Zed/Report/Communication/Table/ProcessResultsTable.php b/src/SprykerMiddleware/Zed/Report/Communication/Table/ProcessResultsTable.php index 467f4a0..98c18b1 100644 --- a/src/SprykerMiddleware/Zed/Report/Communication/Table/ProcessResultsTable.php +++ b/src/SprykerMiddleware/Zed/Report/Communication/Table/ProcessResultsTable.php @@ -97,7 +97,7 @@ protected function prepareData(TableConfiguration $config): array foreach ($queryResults as $item) { $results[] = [ static::COL_ID_PROCESS_RESULT => $item->getIdProcessResult(), - static::COL_START_TIME => $item->getStartTime('Y-m-d h:i:s'), + static::COL_START_TIME => $item->getStartTime('Y-m-d H:i:s'), static::TABLE_COL_DURATION => gmdate("H:i:s", $this->getDuration($item)) . ' (H:i:s)', static::COL_ITEM_COUNT => $item->getItemCount(), static::TABLE_COL_STATUS => $this->getStatus($item), From c456f76054ef026af20ca68587c4bd86dad8f273 Mon Sep 17 00:00:00 2001 From: Valerii Pravoslavnyi Date: Thu, 12 Apr 2018 13:46:36 +0300 Subject: [PATCH 16/25] Updated ReportPostProcessorHookPlugin according to interface changes --- .../Plugin/Hook/ReportPostProcessorHookPlugin.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/SprykerMiddleware/Zed/Report/Communication/Plugin/Hook/ReportPostProcessorHookPlugin.php b/src/SprykerMiddleware/Zed/Report/Communication/Plugin/Hook/ReportPostProcessorHookPlugin.php index 3042728..1b62e6a 100644 --- a/src/SprykerMiddleware/Zed/Report/Communication/Plugin/Hook/ReportPostProcessorHookPlugin.php +++ b/src/SprykerMiddleware/Zed/Report/Communication/Plugin/Hook/ReportPostProcessorHookPlugin.php @@ -12,6 +12,7 @@ */ class ReportPostProcessorHookPlugin extends AbstractPlugin implements PostProcessorHookPluginInterface { + protected const PLUGIN_NAME = 'ReportPostProcessorHookPlugin'; /** * @param \Generated\Shared\Transfer\ProcessResultTransfer|null $processResultTransfer * @@ -22,4 +23,12 @@ public function process(ProcessResultTransfer $processResultTransfer = null): vo $this->getFacade() ->saveProcessResult($processResultTransfer); } + + /** + * @return string + */ + public function getName(): string + { + return static::PLUGIN_NAME; + } } From 1e96d664b907f3dbd8994240b0e709f85e7d58a1 Mon Sep 17 00:00:00 2001 From: vhrychenko Date: Thu, 10 May 2018 13:10:08 +0300 Subject: [PATCH 17/25] dev Added CI files --- .scrutinizer.yml | 18 ++++++++++++++++++ .travis.yml | 23 +++++++++++++++++++++++ composer.json | 15 ++++++++++++++- 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 .scrutinizer.yml create mode 100644 .travis.yml diff --git a/.scrutinizer.yml b/.scrutinizer.yml new file mode 100644 index 0000000..54cef0e --- /dev/null +++ b/.scrutinizer.yml @@ -0,0 +1,18 @@ +build: + dependencies: + before: + - composer config repositories.spryker composer https://code.spryker.com/repo/private + environment: + php: + version: 7.1 + +checks: + php: + code_rating: true + +filter: + excluded_paths: + - config/* + - tests/* + - src/Generated/* + - src/Pyz/* diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..378c005 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,23 @@ +language: php + +php: + - 7.1 + +cache: + directories: + - vendor + - $HOME/.composer/cache + +env: + global: + - APPLICATION_ENV=development + - APPLICATION_STORE=DE + +install: + - composer install --no-interaction --prefer-dist + +script: + - vendor/bin/phpcs src --standard=vendor/spryker/code-sniffer/Spryker/ruleset.xml + +notifications: + email: false diff --git a/composer.json b/composer.json index 4cab41f..e96abab 100644 --- a/composer.json +++ b/composer.json @@ -6,6 +6,9 @@ "php": ">=7.1", "spryker-middleware/process": "dev-dev" }, + "require-dev": { + "spryker/code-sniffer": "*" + }, "autoload": { "psr-4": { "SprykerMiddleware\\": "src/SprykerMiddleware/" @@ -17,5 +20,15 @@ "preferred-install": "dist", "sort-packages": true, "process-timeout": 600 - } + }, + "repositories": [ + { + "type": "git", + "url": "https://github.com/spryker-middleware/process.git" + }, + { + "type": "git", + "url": "https://github.com/spryker-middleware/logger.git" + } + ] } From 76dbe3eeb7c76bd60ab8e6de77fe388b1963b370 Mon Sep 17 00:00:00 2001 From: vhrychenko Date: Thu, 10 May 2018 13:15:01 +0300 Subject: [PATCH 18/25] dev Update README.md --- README.md | 1 + .../Communication/Plugin/Hook/ReportPostProcessorHookPlugin.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d89454f..83cae99 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # Report Module Report module provides reporting functionality for Spryker Middleware +[![Build Status](https://travis-ci.org/spryker-middleware/report.svg?branch=master)](https://travis-ci.org/spryker-middleware/report) ## Installation diff --git a/src/SprykerMiddleware/Zed/Report/Communication/Plugin/Hook/ReportPostProcessorHookPlugin.php b/src/SprykerMiddleware/Zed/Report/Communication/Plugin/Hook/ReportPostProcessorHookPlugin.php index 1b62e6a..a19d8eb 100644 --- a/src/SprykerMiddleware/Zed/Report/Communication/Plugin/Hook/ReportPostProcessorHookPlugin.php +++ b/src/SprykerMiddleware/Zed/Report/Communication/Plugin/Hook/ReportPostProcessorHookPlugin.php @@ -18,7 +18,7 @@ class ReportPostProcessorHookPlugin extends AbstractPlugin implements PostProces * * @return void */ - public function process(ProcessResultTransfer $processResultTransfer = null): void + public function process(?ProcessResultTransfer $processResultTransfer = null): void { $this->getFacade() ->saveProcessResult($processResultTransfer); From 952d712501e0b81911559c63678a82c6d0561709 Mon Sep 17 00:00:00 2001 From: vhrychenko Date: Mon, 14 May 2018 15:31:53 +0300 Subject: [PATCH 19/25] dev Add travis.yml and codeception.yml --- .travis.yml | 54 +++++++++++++++++++++++++++++++++++-------------- codeception.yml | 21 +++++++++++++++++++ 2 files changed, 60 insertions(+), 15 deletions(-) create mode 100644 codeception.yml diff --git a/.travis.yml b/.travis.yml index 378c005..2317655 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,23 +1,47 @@ language: php -php: - - 7.1 +notifications: + email: false -cache: - directories: - - vendor - - $HOME/.composer/cache +sudo: required + +matrix: + fast_finish: true + include: + - php: "7.1" + +services: + - postgresql + - redis + - rabbitmq + +addons: + postgresql: 9.4 + + apt: + packages: + - graphviz + + hosts: + - zed.de.spryker.test + - www.de.spryker.test env: - global: - - APPLICATION_ENV=development - - APPLICATION_STORE=DE + global: + - APPLICATION_ENV=devtest + - APPLICATION_STORE=DE + - MODULE_DIR=module + - SHOP_DIR=current + - MODULE_NAME=report -install: - - composer install --no-interaction --prefer-dist +cache: + directories: + - $SHOP_DIR/current/vendor + - $HOME/.composer/cache -script: - - vendor/bin/phpcs src --standard=vendor/spryker/code-sniffer/Spryker/ruleset.xml +before_install: + - echo "extension = redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini -notifications: - email: false +script: + - git clone -b master https://github.com/spryker-middleware/middleware-ci.git middleware-ci + - ./middleware-ci/build/travis.sh \ No newline at end of file diff --git a/codeception.yml b/codeception.yml new file mode 100644 index 0000000..e297a5a --- /dev/null +++ b/codeception.yml @@ -0,0 +1,21 @@ +namespace: SprykerMiddleware +actor: Tester + +include: + - tests/SprykerMiddlewareTest/Zed/Report + +paths: + tests: tests + log: tests/_output + data: tests/_data + support: tests/_support + envs: tests/_envs +settings: + bootstrap: _bootstrap.php + suite_class: \PHPUnit_Framework_TestSuite + colors: true + memory_limit: 1024M + log: true +coverage: + enabled: true + whitelist: { include: ['src/*'] } From 0d9c62141042a9e7b68e908aed03aa5966889c75 Mon Sep 17 00:00:00 2001 From: vhrychenko Date: Mon, 14 May 2018 15:38:50 +0300 Subject: [PATCH 20/25] dev Update composer.json --- composer.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e96abab..462c86d 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,13 @@ "spryker-middleware/process": "dev-dev" }, "require-dev": { - "spryker/code-sniffer": "*" + "spryker/calculation": "*", + "spryker/cart": "*", + "spryker/code-sniffer": "*", + "spryker/propel": "*", + "spryker/silex": "*", + "spryker/testify": "*", + "spryker/transfer": "*" }, "autoload": { "psr-4": { From 63497c5695da83b6a7fb649ea24df0f175b7dd55 Mon Sep 17 00:00:00 2001 From: vhrychenko Date: Mon, 14 May 2018 19:45:59 +0300 Subject: [PATCH 21/25] dev Add report repository --- composer.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/composer.json b/composer.json index 462c86d..f41c6e9 100644 --- a/composer.json +++ b/composer.json @@ -35,6 +35,10 @@ { "type": "git", "url": "https://github.com/spryker-middleware/logger.git" + }, + { + "type": "git", + "url": "https://github.com/spryker-middleware/report.git" } ] } From 6424f177791d5e4665dc9c40f7ecc19e2da677df Mon Sep 17 00:00:00 2001 From: vhrychenko Date: Mon, 14 May 2018 19:56:01 +0300 Subject: [PATCH 22/25] dev Revert travis.yml --- .travis.yml | 54 +++++++++++++++-------------------------------------- 1 file changed, 15 insertions(+), 39 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2317655..378c005 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,47 +1,23 @@ language: php -notifications: - email: false - -sudo: required - -matrix: - fast_finish: true - include: - - php: "7.1" - -services: - - postgresql - - redis - - rabbitmq - -addons: - postgresql: 9.4 - - apt: - packages: - - graphviz +php: + - 7.1 - hosts: - - zed.de.spryker.test - - www.de.spryker.test +cache: + directories: + - vendor + - $HOME/.composer/cache env: - global: - - APPLICATION_ENV=devtest - - APPLICATION_STORE=DE - - MODULE_DIR=module - - SHOP_DIR=current - - MODULE_NAME=report - -cache: - directories: - - $SHOP_DIR/current/vendor - - $HOME/.composer/cache + global: + - APPLICATION_ENV=development + - APPLICATION_STORE=DE -before_install: - - echo "extension = redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini +install: + - composer install --no-interaction --prefer-dist script: - - git clone -b master https://github.com/spryker-middleware/middleware-ci.git middleware-ci - - ./middleware-ci/build/travis.sh \ No newline at end of file + - vendor/bin/phpcs src --standard=vendor/spryker/code-sniffer/Spryker/ruleset.xml + +notifications: + email: false From 3949f6d975afe043dc6b4b7e6cddcda7bc00d2b6 Mon Sep 17 00:00:00 2001 From: vhrychenko Date: Tue, 15 May 2018 10:03:07 +0300 Subject: [PATCH 23/25] dev Update composer.json --- .travis.yml | 1 + composer.json | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 378c005..10750e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,7 @@ install: script: - vendor/bin/phpcs src --standard=vendor/spryker/code-sniffer/Spryker/ruleset.xml + - vendor/bin/phpmd src text vendor/spryker/architecture-sniffer/src/ruleset.xml --minimumpriority=2 notifications: email: false diff --git a/composer.json b/composer.json index f41c6e9..2d13c5c 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,9 @@ "spryker/propel": "*", "spryker/silex": "*", "spryker/testify": "*", - "spryker/transfer": "*" + "spryker/transfer": "*", + "spryker/architecture-sniffer": "dev-master", + "phpmd/phpmd": "^2.4" }, "autoload": { "psr-4": { From 72c12222cf4da016523e79c1c9f45555c5cf5f52 Mon Sep 17 00:00:00 2001 From: vhrychenko Date: Tue, 15 May 2018 10:07:11 +0300 Subject: [PATCH 24/25] dev Update ReportFactory --- .../Zed/Report/Communication/ReportCommunicationFactory.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/SprykerMiddleware/Zed/Report/Communication/ReportCommunicationFactory.php b/src/SprykerMiddleware/Zed/Report/Communication/ReportCommunicationFactory.php index 9947c8b..65382fb 100644 --- a/src/SprykerMiddleware/Zed/Report/Communication/ReportCommunicationFactory.php +++ b/src/SprykerMiddleware/Zed/Report/Communication/ReportCommunicationFactory.php @@ -10,6 +10,9 @@ use SprykerMiddleware\Zed\Report\Communication\Table\ProcessResultsTable; use SprykerMiddleware\Zed\Report\ReportDependencyProvider; +/** + * @SuppressWarnings(FactoryMethodReturnInterfaceRule) + */ class ReportCommunicationFactory extends AbstractCommunicationFactory { /** From b74dae3084dac2aefbb9df50f370a4a8b642d9b0 Mon Sep 17 00:00:00 2001 From: vhrychenko Date: Tue, 15 May 2018 14:16:05 +0300 Subject: [PATCH 25/25] dev Update version of process --- composer.json | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/composer.json b/composer.json index 2d13c5c..4c4afd3 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "license": "MIT", "require": { "php": ">=7.1", - "spryker-middleware/process": "dev-dev" + "spryker-middleware/process": "^1.0.0" }, "require-dev": { "spryker/calculation": "*", @@ -28,19 +28,5 @@ "preferred-install": "dist", "sort-packages": true, "process-timeout": 600 - }, - "repositories": [ - { - "type": "git", - "url": "https://github.com/spryker-middleware/process.git" - }, - { - "type": "git", - "url": "https://github.com/spryker-middleware/logger.git" - }, - { - "type": "git", - "url": "https://github.com/spryker-middleware/report.git" - } - ] + } }