Пример #1
0
 /**
  * Checks the token table to see if there are any answered surveys to be processed
  *
  * If the survey was started (and the token was forwarded to limesurvey) we need to check
  * if is was completed. If so, we might want to check the track the survey is in to enable
  * or disable future rounds
  *
  * Does not reflect changes to tracks or rounds.
  *
  * @param string $batch_id A unique identifier for the current batch
  * @param \Gems_Tracker_Token_TokenSelect Select statements selecting tokens
  * @param int $userId    Id of the user who takes the action (for logging)
  * @return \Gems_Task_TaskRunnerBatch A batch to process the changes
  */
 protected function processTokensBatch($batch_id, \Gems_Tracker_Token_TokenSelect $tokenSelect, $userId)
 {
     $where = implode(' ', $tokenSelect->getSelect()->getPart(\Zend_Db_Select::WHERE));
     $batch = $this->loader->getTaskRunnerBatch($batch_id);
     //Now set the step duration
     $batch->minimalStepDurationMs = 3000;
     if (!$batch->isLoaded()) {
         $statement = $tokenSelect->getSelect()->query();
         //Process one row at a time to prevent out of memory errors for really big resultsets
         while ($tokenData = $statement->fetch()) {
             $tokenId = $tokenData['gto_id_token'];
             $batch->setTask('Tracker_CheckTokenCompletion', 'tokchk-' . $tokenId, $tokenId, $userId);
             $batch->addToCounter('tokens');
         }
     }
     return $batch;
 }
Пример #2
0
 /**
  * Add relation to the select statement
  *
  * @param Gems_Tracker_Token_TokenSelect $select
  */
 protected function _addRelation($select)
 {
     // now add a left join with the round table so we have all tokens, also the ones without rounds
     if (!is_null($this->_gemsData['gto_id_relation'])) {
         $select->forWhere('gto_id_relation = ?', $this->_gemsData['gto_id_relation']);
     } else {
         $select->forWhere('gto_id_relation IS NULL');
     }
 }