Loading bin/oscar-worker.php +5 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,10 @@ $worker->addFunction('hello', 'oscarJob_hello'); // Affiche dans le journalctl -u oscarworker.service -f $execDev = "2"; echo "OSCAR WORKER STARTED ".\Oscar\OscarVersion::getBuild()." OKOK\n"; echo "###################################################################\n"; echo "# OSCAR WORKER STARTED ".\Oscar\OscarVersion::getBuild()." SPARTAN\n"; echo "# working directory : '" . __DIR__."'\n"; echo "###################################################################\n"; while($worker->work()); Loading Loading @@ -113,6 +116,7 @@ function oscarJob_updateNotificationsActivity(GearmanJob $job){ $activityid = $params->activityid; $cmd = $oscarCmd . ' notificationsactivity \'{"activityid":'. $params->activityid .'}\''; echo "[worker] exec $cmd\n"; exec($cmd); } catch (Exception $e) { echo "[ERR] " . $e->getMessage() ."\n"; Loading module/Oscar/src/Oscar/Command/OscarConsoleCommand.php +1 −8 Original line number Diff line number Diff line Loading @@ -56,20 +56,13 @@ class OscarConsoleCommand extends OscarCommandAbstract $this->getServicemanager()->get('Logger')->debug("command : $action " . $input->getArgument('params')); switch ($action) { case "addpersonactivity": $person = $personService->getPersonById($params['personid'], true); $activity = $projectGrantService->getActivityById($params['activityid']); $role = $oscaruserContext->getRoleByRoleId($params['roleid']); $personService->personActivityAdd($activity, $person, $role); break; case "notificationsactivity": $command = $this->getApplication()->find(OscarCommandAbstract::COMMAND_ACTIVITY_NOTIFICATION_UPDATE); $arguments = [ OscarActivitySearchReindexCommand::ARGUMENT_ACTIVITY_ID => $params['activityid'], OscarActivityNotificationUpdateCommand::ARGUMENT_ACTIVITY_ID => $params['activityid'], '--force' => null ]; Loading module/Oscar/src/Oscar/Command/OscarNotificationsRebuildCommand.php +28 −17 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ namespace Oscar\Command; use Exception; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class OscarNotificationsRebuildCommand extends OscarAdvancedCommandAbstract Loading @@ -18,24 +19,25 @@ class OscarNotificationsRebuildCommand extends OscarAdvancedCommandAbstract protected static $defaultName = OscarCommandAbstract::COMMAND_NOTIFICATIONS_REBUILD; const OPTION_INCLUDE_PAST = 'include-past'; const OPTION_PURGE = 'purge-old'; const OPTION_PURGE = 'purge'; protected function configure() { parent::configure(); $this ->setDescription("Reconstruction des notifications des activités de recherche") ->addOption( self::OPTION_INCLUDE_PAST, null, InputArgument::OPTIONAL, "Forcer le recalcule des notifications pour les activités" ) // ->addOption( // self::OPTION_INCLUDE_PAST, // null, // InputArgument::OPTIONAL, // "Forcer le recalcule des notifications pour les activités" // ) ->addOption( self::OPTION_PURGE, null, InputArgument::OPTIONAL, "Supprime TOUTES les notifications avant de recalculer" 'p', InputOption::VALUE_OPTIONAL, "Supprime TOUTES les notifications avant de recalculer", false ); } Loading @@ -43,14 +45,22 @@ class OscarNotificationsRebuildCommand extends OscarAdvancedCommandAbstract { parent::execute($input, $output); $includePast = $input->getOption(self::OPTION_INCLUDE_PAST); //$includePast = $input->getOption(self::OPTION_INCLUDE_PAST); $purgeBefore = $input->getOption(self::OPTION_PURGE); var_dump($purgeBefore); try { // TODO Récupérer les activités en fonction des critères $activities = $this->getProjectGrantService()->getActivityRepository()->getActivitiesActive(); if ($purgeBefore !== false ) { if (!$this->ask("Purger les notifications ? ")) { return 0; } $this->notice("Suppression des notifications..."); $this->getProjectGrantService()->getNotificationService()->purgeNotificationsAll(); } if (!$this->ask("Recalculer les notifications pour ces " . count($activities) . " activité(s) ?")) { return 0; } Loading @@ -65,7 +75,8 @@ class OscarNotificationsRebuildCommand extends OscarAdvancedCommandAbstract } return $this->finalSuccess("Les notifications ont été recalculées"); } catch (Exception $e) { } catch (Exception $e) { return $this->finalFatalError($e); } } Loading module/Oscar/src/Oscar/Controller/ProjectGrantController.php +2 −1 Original line number Diff line number Diff line Loading @@ -778,7 +778,8 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif $form->setData($request->getPost()); if ($form->isValid()) { $this->getEntityManager()->flush($projectGrant); $this->getActivityService()->jobSearchUpdate($projectGrant); $this->getActivityService()->getGearmanJobLauncherService()->triggerUpdateNotificationActivity($projectGrant); $this->getActivityService()->getGearmanJobLauncherService()->triggerUpdateSearchIndexActivity($projectGrant); $this->redirect()->toRoute( 'contract/show', ['id' => $projectGrant->getId()] Loading module/Oscar/src/Oscar/Entity/NotificationRepository.php +24 −3 Original line number Diff line number Diff line Loading @@ -107,4 +107,25 @@ class NotificationRepository extends EntityRepository ); return $qb->getQuery()->execute(); } public function purgeAll() { $dql = 'DELETE ' . Notification::class; $this->getEntityManager()->createQuery($dql)->getResult(); } protected function getQueryBuilderDeleteBase() { return $this->getBaseQueryBuilder() ->delete(); } /** * @return \Doctrine\ORM\QueryBuilder */ protected function getBaseQueryBuilder() { return $this->createQueryBuilder('n'); } } No newline at end of file Loading
bin/oscar-worker.php +5 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,10 @@ $worker->addFunction('hello', 'oscarJob_hello'); // Affiche dans le journalctl -u oscarworker.service -f $execDev = "2"; echo "OSCAR WORKER STARTED ".\Oscar\OscarVersion::getBuild()." OKOK\n"; echo "###################################################################\n"; echo "# OSCAR WORKER STARTED ".\Oscar\OscarVersion::getBuild()." SPARTAN\n"; echo "# working directory : '" . __DIR__."'\n"; echo "###################################################################\n"; while($worker->work()); Loading Loading @@ -113,6 +116,7 @@ function oscarJob_updateNotificationsActivity(GearmanJob $job){ $activityid = $params->activityid; $cmd = $oscarCmd . ' notificationsactivity \'{"activityid":'. $params->activityid .'}\''; echo "[worker] exec $cmd\n"; exec($cmd); } catch (Exception $e) { echo "[ERR] " . $e->getMessage() ."\n"; Loading
module/Oscar/src/Oscar/Command/OscarConsoleCommand.php +1 −8 Original line number Diff line number Diff line Loading @@ -56,20 +56,13 @@ class OscarConsoleCommand extends OscarCommandAbstract $this->getServicemanager()->get('Logger')->debug("command : $action " . $input->getArgument('params')); switch ($action) { case "addpersonactivity": $person = $personService->getPersonById($params['personid'], true); $activity = $projectGrantService->getActivityById($params['activityid']); $role = $oscaruserContext->getRoleByRoleId($params['roleid']); $personService->personActivityAdd($activity, $person, $role); break; case "notificationsactivity": $command = $this->getApplication()->find(OscarCommandAbstract::COMMAND_ACTIVITY_NOTIFICATION_UPDATE); $arguments = [ OscarActivitySearchReindexCommand::ARGUMENT_ACTIVITY_ID => $params['activityid'], OscarActivityNotificationUpdateCommand::ARGUMENT_ACTIVITY_ID => $params['activityid'], '--force' => null ]; Loading
module/Oscar/src/Oscar/Command/OscarNotificationsRebuildCommand.php +28 −17 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ namespace Oscar\Command; use Exception; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class OscarNotificationsRebuildCommand extends OscarAdvancedCommandAbstract Loading @@ -18,24 +19,25 @@ class OscarNotificationsRebuildCommand extends OscarAdvancedCommandAbstract protected static $defaultName = OscarCommandAbstract::COMMAND_NOTIFICATIONS_REBUILD; const OPTION_INCLUDE_PAST = 'include-past'; const OPTION_PURGE = 'purge-old'; const OPTION_PURGE = 'purge'; protected function configure() { parent::configure(); $this ->setDescription("Reconstruction des notifications des activités de recherche") ->addOption( self::OPTION_INCLUDE_PAST, null, InputArgument::OPTIONAL, "Forcer le recalcule des notifications pour les activités" ) // ->addOption( // self::OPTION_INCLUDE_PAST, // null, // InputArgument::OPTIONAL, // "Forcer le recalcule des notifications pour les activités" // ) ->addOption( self::OPTION_PURGE, null, InputArgument::OPTIONAL, "Supprime TOUTES les notifications avant de recalculer" 'p', InputOption::VALUE_OPTIONAL, "Supprime TOUTES les notifications avant de recalculer", false ); } Loading @@ -43,14 +45,22 @@ class OscarNotificationsRebuildCommand extends OscarAdvancedCommandAbstract { parent::execute($input, $output); $includePast = $input->getOption(self::OPTION_INCLUDE_PAST); //$includePast = $input->getOption(self::OPTION_INCLUDE_PAST); $purgeBefore = $input->getOption(self::OPTION_PURGE); var_dump($purgeBefore); try { // TODO Récupérer les activités en fonction des critères $activities = $this->getProjectGrantService()->getActivityRepository()->getActivitiesActive(); if ($purgeBefore !== false ) { if (!$this->ask("Purger les notifications ? ")) { return 0; } $this->notice("Suppression des notifications..."); $this->getProjectGrantService()->getNotificationService()->purgeNotificationsAll(); } if (!$this->ask("Recalculer les notifications pour ces " . count($activities) . " activité(s) ?")) { return 0; } Loading @@ -65,7 +75,8 @@ class OscarNotificationsRebuildCommand extends OscarAdvancedCommandAbstract } return $this->finalSuccess("Les notifications ont été recalculées"); } catch (Exception $e) { } catch (Exception $e) { return $this->finalFatalError($e); } } Loading
module/Oscar/src/Oscar/Controller/ProjectGrantController.php +2 −1 Original line number Diff line number Diff line Loading @@ -778,7 +778,8 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif $form->setData($request->getPost()); if ($form->isValid()) { $this->getEntityManager()->flush($projectGrant); $this->getActivityService()->jobSearchUpdate($projectGrant); $this->getActivityService()->getGearmanJobLauncherService()->triggerUpdateNotificationActivity($projectGrant); $this->getActivityService()->getGearmanJobLauncherService()->triggerUpdateSearchIndexActivity($projectGrant); $this->redirect()->toRoute( 'contract/show', ['id' => $projectGrant->getId()] Loading
module/Oscar/src/Oscar/Entity/NotificationRepository.php +24 −3 Original line number Diff line number Diff line Loading @@ -107,4 +107,25 @@ class NotificationRepository extends EntityRepository ); return $qb->getQuery()->execute(); } public function purgeAll() { $dql = 'DELETE ' . Notification::class; $this->getEntityManager()->createQuery($dql)->getResult(); } protected function getQueryBuilderDeleteBase() { return $this->getBaseQueryBuilder() ->delete(); } /** * @return \Doctrine\ORM\QueryBuilder */ protected function getBaseQueryBuilder() { return $this->createQueryBuilder('n'); } } No newline at end of file