Commit 16a207ed authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

- code format

- Suppression de logs (debug)
- Ajout d'un log (notice) sur la commande de recalcule des notifications
parent bc2dd67b
Loading
Loading
Loading
Loading
Loading
+28 −28
Original line number Diff line number Diff line
@@ -45,14 +45,18 @@ echo "# OSCAR WORKER STARTED ".\Oscar\OscarVersion::getBuild()." SPARTAN\n";
echo "# working directory : '" . __DIR__ . "'\n";
echo "###################################################################\n";

while($worker->work());
while ($worker->work()) {
    ;
}

function getServiceManager(){
function getServiceManager()
{
    global $app;
    return $app->getServiceManager();
}

function oscarJob_updateIndexActivity(GearmanJob $job){
function oscarJob_updateIndexActivity(GearmanJob $job)
{
    global $oscarCmd;
    $params = json_decode($job->workload());
    try {
@@ -63,13 +67,13 @@ function oscarJob_updateIndexActivity(GearmanJob $job){
        $cmd = $oscarCmd . ' indexactivity \'{"activityid":' . $params->activityid . '}\'';
        echo "[worker] exec $cmd\n";
        exec($cmd);

    } catch (Exception $e) {
        echo "[ERR] " . $e->getMessage() . "\n";
    }
}

function oscarJob_updateIndexPerson(GearmanJob $job){
function oscarJob_updateIndexPerson(GearmanJob $job)
{
    global $oscarCmd;
    $params = json_decode($job->workload());
    try {
@@ -80,14 +84,13 @@ function oscarJob_updateIndexPerson(GearmanJob $job){
        $cmd = $oscarCmd . ' indexperson \'{"personid":' . $personid . '}\'';
        echo "[worker] exec $cmd\n";
        exec($cmd);


    } catch (Exception $e) {
        echo "[ERR] " . $e->getMessage() . "\n";
    }
}

function oscarJob_updateIndexOrganization(GearmanJob $job){
function oscarJob_updateIndexOrganization(GearmanJob $job)
{
    global $oscarCmd;
    $params = json_decode($job->workload());
    try {
@@ -98,13 +101,13 @@ function oscarJob_updateIndexOrganization(GearmanJob $job){
        $cmd = $oscarCmd . ' indexorganization \'{"organizationid":' . $organizationid . '}\'';
        echo "[worker] exec $cmd\n";
        exec($cmd);

    } catch (Exception $e) {
        echo "[ERR] " . $e->getMessage() . "\n";
    }
}

function oscarJob_updateNotificationsActivity(GearmanJob $job){
function oscarJob_updateNotificationsActivity(GearmanJob $job)
{
    global $oscarCmd;

    $params = json_decode($job->workload());
@@ -117,18 +120,16 @@ function oscarJob_updateNotificationsActivity(GearmanJob $job){
        $cmd = $oscarCmd . ' notificationsactivity \'{"activityid":' . $params->activityid . '}\'';
        echo "[worker] exec $cmd\n";
        exec($cmd);

    } catch (Exception $e) {
        echo "[ERR] " . $e->getMessage() . "\n";
    }
}

function oscarJob_hello(GearmanJob $job){
function oscarJob_hello(GearmanJob $job)
{
    $params = json_decode($job->workload());

    try {


        /** @var \Oscar\Service\ProjectGrantService $projectGrantService */
        $projectGrantService = getServiceManager()->get(\Oscar\Service\ProjectGrantService::class);

@@ -147,7 +148,6 @@ function oscarJob_hello(GearmanJob $job){
        getServiceManager()->get('Logger')->info(" > [gearman:call] TEST OK]");

        $job->sendComplete("TRAITEMENT RÉUSSI");

    } catch (Exception $e) {
        $job->sendException("[ERR] HELLO FAIL : " . $e->getMessage());
    }
+1 −1
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ class OscarActivityNotificationUpdateCommand extends OscarAdvancedCommandAbstrac
            }
            $this->getProjectGrantService()->getNotificationService()->updateNotificationsActivity($activity);

            return $this->finalSuccess("Notifications pour '$activity' mises à jour");
            return $this->finalSuccess("Notifications mises à jour '$activity'");
        } catch (Exception $e) {
            return $this->finalFatalError($e);
        }
+2 −2
Original line number Diff line number Diff line
@@ -136,7 +136,7 @@ abstract class OscarAdvancedCommandAbstract extends OscarCommandAbstract
     */
    protected function finalFatalError(\Exception $e): int
    {
        $this->getLoggerService()->error($e->getMessage());
        $this->getLoggerService()->error("CMD error : " . $e->getMessage());
        if( !$this->getIO()->isQuiet() ) {
            $this->getIO()->error($e->getMessage());
        }
@@ -151,7 +151,7 @@ abstract class OscarAdvancedCommandAbstract extends OscarCommandAbstract
     */
    protected function finalSuccess( string $message ):int
    {
        $this->getLoggerService()->notice($message);
        $this->getLoggerService()->notice("CMD success : " . $message);
        if( !$this->io->isQuiet() ){
            $this->getIO()->success($message);
        }
+0 −1
Original line number Diff line number Diff line
@@ -56,7 +56,6 @@ class OscarConsoleCommand extends OscarCommandAbstract
        $this->getServicemanager()->get('Logger')->debug("command : $action " . $input->getArgument('params'));

        switch ($action) {

            case "notificationsactivity":

                $command = $this->getApplication()->find(OscarCommandAbstract::COMMAND_ACTIVITY_NOTIFICATION_UPDATE);
+9 −3
Original line number Diff line number Diff line
@@ -79,7 +79,9 @@ use Zend\View\Renderer\PhpRenderer;
 *
 * @package Oscar\Controller
 */
class ProjectGrantController extends AbstractOscarController implements UseNotificationService, UsePersonService, UseServiceContainer, UseProjectService, UseSpentService, UsePCRUService
class ProjectGrantController extends AbstractOscarController implements UseNotificationService, UsePersonService,
                                                                        UseServiceContainer, UseProjectService,
                                                                        UseSpentService, UsePCRUService
{

    use UseNotificationServiceTrait, UsePersonServiceTrait, UseServiceContainerTrait, UseProjectServiceTrait, UseSpentServiceTrait, UsePCRUServiceTrait;
@@ -778,8 +780,12 @@ class ProjectGrantController extends AbstractOscarController implements UseNotif
            $form->setData($request->getPost());
            if ($form->isValid()) {
                $this->getEntityManager()->flush($projectGrant);
                $this->getActivityService()->getGearmanJobLauncherService()->triggerUpdateNotificationActivity($projectGrant);
                $this->getActivityService()->getGearmanJobLauncherService()->triggerUpdateSearchIndexActivity($projectGrant);
                $this->getActivityService()->getGearmanJobLauncherService()->triggerUpdateNotificationActivity(
                    $projectGrant
                );
                $this->getActivityService()->getGearmanJobLauncherService()->triggerUpdateSearchIndexActivity(
                    $projectGrant
                );
                $this->redirect()->toRoute(
                    'contract/show',
                    ['id' => $projectGrant->getId()]
Loading