/** * @return SrImportList */ public function getImportList() { switch ($this->settingService->get('shop_type')) { case $this->ShopRenterId: return new SrImportList(); } }
/** * @Route("/product_placement_tester", name="Product Placement Tester") */ public function indexAction(Request $request) { if ($request->query->get('user_id')) { $this->userId = $request->query->get('user_id'); } $this->entityManager = $this->getDoctrine()->getManager('customer' . $this->userId); $this->settingService = $this->get('setting'); $this->settingService->setEntityManager($this->entityManager); $this->baseStatistics = $this->get('BaseStatistics'); $this->baseStatistics->setUserId($this->userId); $this->baseStatistics->setEntityManager($this->entityManager); $this->baseStatistics->setTimeKey($this->timeKey); $accuracy = round(100 - ($this->baseStatistics->get('CheatCount') + $this->baseStatistics->get('NullStatisticsCount') / 2) / $this->baseStatistics->get('ProductCount') * 100); if ($request->query->get('export')) { $time = new \DateTime(); $timestamp = $time->format('YmdHis'); $this->exportFileName = 'export-' . $this->userId . '-' . $timestamp; $this->exportUrl = 'downloads/' . $this->exportFileName . '.xlsx'; $this->export(); } $i = 0; $reports[$i]['A'] = array('version' => 'A', 'reportId' => 'star-products', 'reportName' => 'Star Products', 'reportArray' => $this->getReportBlockRows('StarProducts', 'A'), 'reportConditions' => array('Conversion > 0', 'TOP 100 Unique Views'), 'reportOrders' => array('Conversion decreasing', 'Unique Views decreasing')); $reports[$i]['B'] = array('version' => 'B', 'reportId' => 'star-products', 'reportName' => 'Star Products', 'reportArray' => $this->getReportBlockRows('StarProducts', 'B'), 'reportConditions' => array('Unique Views > {Avg Unique Views * 3}', 'Conversion > {Avg Conversion * 3}'), 'reportOrders' => array('Score ( {Conversion * 10} + {Unique Orders * 5} + {Unique Views * 2} ) decreasing', 'Conversion decreasing', 'Unique Views decreasing')); $i++; $reports[$i]['A'] = array('version' => 'A', 'reportId' => 'potentials', 'reportName' => 'Potentials', 'reportArray' => $this->getReportBlockRows('Potentials', 'A'), 'reportConditions' => array('Conversion > 0', 'LAST 100 Unique Views'), 'reportOrders' => array('Conversion decreasing', 'Unique Views ascending')); $reports[$i]['B'] = array('version' => 'B', 'reportId' => 'potentials', 'reportName' => 'Potentials', 'reportArray' => $this->getReportBlockRows('Potentials', 'B'), 'reportConditions' => array('Unique Views <= {Avg Unique Views * 3}', 'Conversion > 0'), 'reportOrders' => array('Conversion decreasing', 'Unique Views decreasing')); $i++; $reports[$i]['A'] = array('version' => 'A', 'reportId' => 'black-horses', 'reportName' => 'Black Horses', 'reportArray' => $this->getReportBlockRows('BlackHorses', 'A'), 'reportConditions' => array('TOP 100 Unique Views'), 'reportOrders' => array('Conversion ascending', 'Unique Views decreasing')); $reports[$i]['B'] = array('version' => 'B', 'reportId' => 'black-horses', 'reportName' => 'Black Horses', 'reportArray' => $this->getReportBlockRows('BlackHorses', 'B'), 'reportConditions' => array('Unique Views > {Avg Unique Views * 3}', 'Conversion <= Avg Conversion'), 'reportOrders' => array('Conversion ascending', 'Unique Views decreasing')); $i++; $reports[$i]['A'] = array('version' => 'A', 'reportId' => 'end-of-list', 'reportName' => 'End Of List', 'reportArray' => $this->getReportBlockRows('EndOfList', 'A'), 'reportConditions' => array('Conversion = 0'), 'reportOrders' => array('Unique Views ascending', 'Views ascending', 'Available Date ascending')); $reports[$i]['B'] = array('version' => 'B', 'reportId' => 'end-of-list', 'reportName' => 'End Of List', 'reportArray' => $this->getReportBlockRows('EndOfList', 'B'), 'reportConditions' => array('LAST 100 Unique Views at all times', 'Unique Views at all times > 0', 'Unique Views at all times <= {Avg Unique Views * 3}', 'Conversion at all times <= Avg Conversion'), 'reportOrders' => array('Conversion ascending', 'Unique Views ascending', 'Views ascending', 'Available Date ascending')); $i++; $reports[$i]['A'] = array('version' => 'A', 'reportId' => 'difficult-cases', 'reportName' => 'Difficult Cases', 'reportArray' => $this->getReportBlockRows('DifficultCases', 'A'), 'reportConditions' => array('LAST 100 Unique Views'), 'reportOrders' => array('Conversion ascending', 'Unique Views ascending')); $reports[$i]['B'] = array('version' => 'B', 'reportId' => 'difficult-cases', 'reportName' => 'Difficult Cases', 'reportArray' => $this->getReportBlockRows('DifficultCases', 'B'), 'reportConditions' => array('Unique Views > Avg Unique Views', 'Unique Views <= {Avg Unique Views * 3}', 'Conversion <= Avg Conversion'), 'reportOrders' => array('Conversion ascending', 'Unique Views ascending')); $i++; return $this->render('AppBundle:tester:product_placement.html.twig', array('reportList' => $reports, 'lastUpdate' => $this->getLastUpdateTime(), 'avgUniqueViews' => $this->baseStatistics->get('AvgUniqueViews'), 'avgConversion' => $this->baseStatistics->get('AvgConversion'), 'avgUniqueViewsAtInteractiveProducts' => $this->baseStatistics->get('AvgUniqueViewsAtInteractiveProducts'), 'avgConversionAtInteractiveProducts' => $this->baseStatistics->get('AvgConversionAtInteractiveProducts'), 'lastAvgUniqueViews' => $this->baseStatistics->get('AvgUniqueViews', 'lastMonthly'), 'lastAvgConversion' => $this->baseStatistics->get('AvgConversion', 'lastMonthly'), 'lastAvgUniqueViewsAtInteractiveProducts' => $this->baseStatistics->get('AvgUniqueViewsAtInteractiveProducts', 'lastMonthly'), 'lastAvgConversionAtInteractiveProducts' => $this->baseStatistics->get('AvgConversionAtInteractiveProducts', 'lastMonthly'), 'cheatCount' => $this->baseStatistics->get('CheatCount'), 'productCount' => $this->baseStatistics->get('ProductCount'), 'nullStatisticsCount' => $this->baseStatistics->get('NullStatisticsCount'), 'accuracy' => $accuracy, 'exportUrl' => $this->exportUrl)); }
/** * @param ImportScheduleLog $schedule * @throws \CronBundle\Import\Exception */ protected function runOneUserImports(ImportScheduleLog $schedule) { $schedule->setIsLock(1); $this->globalEntityManager->persist($schedule); $this->globalEntityManager->flush(); $this->importLog->resetUserLogData(); $this->importLog->addMessage('user selected => ' . $schedule->getUserId()); //TODO Biztosítani kell, hogy az adott user adatbázis kapcsolata legyen behúzva //Ezt most configból veszi $this->userEntityManager = $this->getDoctrine()->getManager('customer' . $schedule->getUserId()); $this->userEntityManager->clear(); $this->settingService = $this->get('setting'); $this->settingService->setEntityManager($this->userEntityManager); $this->AnalyticsService = $this->get('AnalyticsService'); $this->importListFactoryService = $this->get('ImportListFactory'); $importIndex = $schedule->getActualImportIndex(); $importList = $this->importListFactoryService->getImportList(); $importList->setImporterClassNameSpace($this->getParameter('importerClassNameSpace')); $importList->setImporterComponentFactoryNameSpace($this->getParameter('importerComponentFactoryNameSpace')); $iterator = new ImporterIterator($importList); $iterator->setActualImportIndex($importIndex); while ($iterator->hasImport()) { if (!$this->isInTimeLimit()) { $this->importLog->addMessage('reached user time limit => ' . $schedule->getUserId()); break; } if (!$this->isInUserFailLimit($schedule)) { $this->importLog->addMessage('reached user ERROR limit => ' . $schedule->getUserId()); //TODO e-mail küldés break; } $this->importLog->addMessage('import selected => ' . $importIndex); $importer = $iterator->getActualImport(); $importer->setSettingService($this->settingService); $importer->setAnalyticsService($this->AnalyticsService); $importer->setEntityManager($this->userEntityManager); $importer->setImportLog($this->importLog); $importer->setRuntimeWatcher($this->runtimeWatcher); $this->importLog->addMessage('import run => ' . $importIndex); $importer->init(); $importer->import(); if ($importer->getError()) { $this->importLog->addMessage('import ERROR in run => ' . $importIndex); $importIndex = $iterator->getActualImportIndex(); $schedule->setActualImportIndex($importIndex); $schedule->setUpdateDate(); $failedCounter = $schedule->getFailedCounter() + 1; $schedule->setFailedCounter($failedCounter); $this->failedCounter++; continue; } $this->importLog->addMessage('import success run => ' . $importIndex . ' | ' . $this->importLog->getAllProcessItemCount()); if (!$importer->isFinishedImport()) { $iterator->setActualImportIndex($importIndex); $this->importLog->addMessage('import NOT finished => ' . $importIndex); continue; } $this->importLog->addMessage('import finished => ' . $importIndex); $iterator->setNextImportIndex(); $importIndex = $iterator->getActualImportIndex(); $schedule->setActualImportIndex($importIndex); $schedule->setUpdateDate(); if (!$iterator->hasImport()) { $schedule->setActualImportIndex(1); $schedule->setLastFinishedImportDate(new \DateTime()); $schedule->setPriority(0); $this->importLog->addMessage('all import finished => ' . $schedule->getUserId()); continue; } $this->importLog->addMessage('all import NOT finished => ' . $schedule->getUserId()); $this->globalEntityManager->flush(); } $schedule->setIsLock(0); $this->globalEntityManager->persist($schedule); $this->globalEntityManager->flush(); }