public function doAction() { if (empty($this->id_project)) { $this->result['errors'] = array(-1, "No id project provided"); return -1; } $status = $this->act == 'cancel' ? 'CANCEL' : 'NEW'; $res = changeProjectStatus($this->id_project, $status); }
public function tryToCloseProject($pid, $child_process_id) { if (!empty($pid)) { $_pid = $pid; } else { $_pid = $this->queueTotalID; } $project_totals = array(); $project_totals['project_segments'] = $this->getRedisClient()->get(Constants_AnalysisRedisKeys::PROJECT_TOT_SEGMENTS . $pid); $project_totals['num_analyzed'] = $this->getRedisClient()->get(Constants_AnalysisRedisKeys::PROJECT_NUM_SEGMENTS_DONE . $pid); $project_totals['eq_wc'] = $this->getRedisClient()->get(Constants_AnalysisRedisKeys::PROJ_EQ_WORD_COUNT . $pid) / 1000; $project_totals['st_wc'] = $this->getRedisClient()->get(Constants_AnalysisRedisKeys::PROJ_ST_WORD_COUNT . $pid) / 1000; Log::doLog("--- (child {$child_process_id}) : count segments in project {$pid} = " . $project_totals['project_segments'] . ""); Log::doLog("--- (child {$child_process_id}) : Analyzed segments in project {$pid} = " . $project_totals['num_analyzed'] . ""); if (empty($project_totals['project_segments'])) { Log::doLog("--- (child {$child_process_id}) : WARNING !!! error while counting segments in projects {$pid} skipping and continue "); return; } if ($project_totals['project_segments'] - $project_totals['num_analyzed'] == 0 && $this->getRedisClient()->setnx(Constants_AnalysisRedisKeys::PROJECT_ENDING_SEMAPHORE . $pid, 1)) { $this->getRedisClient()->expire(Constants_AnalysisRedisKeys::PROJECT_ENDING_SEMAPHORE . $pid, 60 * 60 * 24); $_analyzed_report = getProjectSegmentsTranslationSummary($pid); $total_segs = array_pop($_analyzed_report); //remove Rollup Log::doLog("--- (child {$child_process_id}) : analysis project {$pid} finished : change status to DONE"); changeProjectStatus($pid, Constants_ProjectStatus::STATUS_DONE); changeTmWc($pid, $project_totals['eq_wc'], $project_totals['st_wc']); /* * Remove this job from the project list */ $this->getRedisClient()->lrem(Constants_AnalysisRedisKeys::PROJECTS_QUEUE_LIST, 0, $_pid); Log::doLog("--- (child {$child_process_id}) : trying to initialize job total word count."); foreach ($_analyzed_report as $job_info) { $counter = new WordCount_Counter(); $counter->initializeJobWordCount($job_info['id_job'], $job_info['password']); } } }
function updateProject($pid, $status) { _TimeStampMsg("changing project status..."); $change_res = changeProjectStatus($pid, $status); if ($change_res < 0) { } _TimeStampMsg("done"); }
/** * @param $_project_id */ protected function _tryToCloseProject($_project_id) { $project_totals = array(); $project_totals['project_segments'] = $this->_queueHandler->getRedisClient()->get(RedisKeys::PROJECT_TOT_SEGMENTS . $_project_id); $project_totals['num_analyzed'] = $this->_queueHandler->getRedisClient()->get(RedisKeys::PROJECT_NUM_SEGMENTS_DONE . $_project_id); $project_totals['eq_wc'] = $this->_queueHandler->getRedisClient()->get(RedisKeys::PROJ_EQ_WORD_COUNT . $_project_id) / 1000; $project_totals['st_wc'] = $this->_queueHandler->getRedisClient()->get(RedisKeys::PROJ_ST_WORD_COUNT . $_project_id) / 1000; $this->_doLog("--- (Worker {$this->_workerPid}) : count segments in project {$_project_id} = " . $project_totals['project_segments'] . ""); $this->_doLog("--- (Worker {$this->_workerPid}) : Analyzed segments in project {$_project_id} = " . $project_totals['num_analyzed'] . ""); if (empty($project_totals['project_segments'])) { $this->_doLog("--- (Worker {$this->_workerPid}) : WARNING !!! error while counting segments in projects {$_project_id} skipping and continue "); return; } if ($project_totals['project_segments'] - $project_totals['num_analyzed'] == 0 && $this->_queueHandler->getRedisClient()->setnx(RedisKeys::PROJECT_ENDING_SEMAPHORE . $_project_id, 1)) { $this->_queueHandler->getRedisClient()->expire(RedisKeys::PROJECT_ENDING_SEMAPHORE . $_project_id, 60 * 60 * 24); $_analyzed_report = getProjectSegmentsTranslationSummary($_project_id); $total_segs = array_pop($_analyzed_report); //remove Rollup $this->_doLog("--- (Worker {$this->_workerPid}) : analysis project {$_project_id} finished : change status to DONE"); changeProjectStatus($_project_id, \Constants_ProjectStatus::STATUS_DONE); changeTmWc($_project_id, $project_totals['eq_wc'], $project_totals['st_wc']); /* * Remove this job from the project list */ $this->_queueHandler->getRedisClient()->lrem($this->_mySubscribedQueue->redis_key, 0, $_project_id); $this->_doLog("--- (Worker {$this->_workerPid}) : trying to initialize job total word count."); foreach ($_analyzed_report as $job_info) { $counter = new \WordCount_Counter(); $counter->initializeJobWordCount($job_info['id_job'], $job_info['password']); } } }
function tryToCloseProject($pid) { global $my_pid; $segs_in_project = countSegments($pid); if ($segs_in_project < 0) { echo "--- (child {$my_pid}) : WARNING !!! error while counting segments in projects {$pid} skipping and continue \n"; return; } echo "--- (child {$my_pid}) : count segments in project {$pid} = {$segs_in_project}\n"; $analyzed_report = countSegmentsTranslationAnalyzed($pid); $segs_analyzed = $analyzed_report['num_analyzed']; $pid_eq_words = $analyzed_report['eq_wc']; $pid_standard_words = $analyzed_report['st_wc']; if ($segs_in_project - $segs_analyzed == 0) { echo "--- (child {$my_pid}) : analysis project {$pid} finished : change status to DONE\n"; $change_res = changeProjectStatus($pid, Constants_ProjectStatus::STATUS_DONE); $tm_wc_res = changeTmWc($pid, $pid_eq_words, $pid_standard_words); } echo "\n\n"; }
protected function _updateProject($pid, $status) { self::_TimeStampMsg("*** Project {$pid}: Changing status..."); changeProjectStatus($pid, $status); self::_TimeStampMsg("*** Project {$pid}: {$status}"); }