Returns all surveys for synchronization

@return array Pairs gemsId => sourceId
961451
protected function _getGemsSurveysForSynchronisation()
    {
        $select = $this->_gemsDb->select();
        $select->from('gems__surveys', array('gsu_id_survey', 'gsu_surveyor_id'))
                ->where('gsu_id_source = ?', $this->getId())
                ->order('gsu_surveyor_id');

        return $this->_gemsDb->fetchPairs($select);
    }
1248460
protected function getMissingEntities()
    {
        $modes = $this->getAllModes();
        $entrySubtypes = $this->getEntrySubtypes();
        
        $classes = array();
        foreach ($entrySubtypes as $service => $subtypes) {
            foreach ($modes as $mode) {
                foreach ($subtypes as $subtype) {
                    $classes[] = sprintf(
                        self::MODE_PATTERN,
                        $service,
                        $mode,
                        $service . $subtype . $mode
                    );
                }
            }
        }
        
        return $this->getMissingClasses($classes);
    }
486992
def list_surveys
      url = ApiRequest.base_path("questionpro.survey.getAllSurveys")
      result = self.class.get(url, body: self.options)
      
      self.full_response = result
      self.status = result['status']
      
      surveys = []
      result_surveys = result['response']['surveys']
      result_surveys.each do |survey|
        surveys.push(Survey.new(survey))
      end     

      return surveys
    end
640467
public function getSurveyId()
    {
        $sid = $this->_getParam(\Gems_Model::SURVEY_ID);
        if ($sid) {
            return $sid;
        }
        if ($this->getTokenId()) {
            return $this->getToken()->getSurveyId();
        }
    }
750787
public function getCompletedTokens($tokenIds, $sourceSurveyId)
    {
        $lsDb       = $this->getSourceDatabase();
        $lsToken   = $this->_getTokenTableName($sourceSurveyId);

        // Make sure we use tokens in the format LimeSurvey likes
        $tokens = array_map(array($this, '_getToken'), $tokenIds);

        $sql = $lsDb->select()
                ->from($lsToken, array('token'))
                ->where('token IN (?)', $tokens)
                ->where('completed != ?', 'N');

        $completedTokens = $lsDb->fetchCol($sql);

        // Now make sure we return tokens GemsTracker likes
        if ($completedTokens) {
            $translatedTokens = array();

            // Can not use the map function here since we need a second parameter
            foreach($completedTokens as $token) {
                $translatedTokens[] = $this->_getToken($token, true);
            }

            return $translatedTokens;
        }

        return $completedTokens;
    }
426789
public function listBranches(): array
    {
        return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/branches', $this->getOwner(),
            $this->getRepo()));
    }
869668
public function getRawAnswers()
    {
        if (! is_array($this->_sourceDataRaw)) {
            $this->_sourceDataRaw = $this->getSurvey()->getRawTokenAnswerRow($this->_tokenId);
        }
        return $this->_sourceDataRaw;
    }
1320231
public function getAllProfilesAction()
    {
        $profiles = [];
        /** @var Repository $repo */
        $repo = $this->get($this->getParameter('ongr_settings.repo'));

        $search = $repo->createSearch();
        $search->addAggregation(new TermsAggregation('profiles', 'profile'));

        /** @var DocumentIterator $result */
        $result = $repo->findDocuments($search);

        /** @var AggregationValue $agg */
        foreach ($result->getAggregation('profiles') as $agg) {
            $profiles[] = $agg->getValue('key');
        }

        if (empty($profiles) || !in_array('default', $profiles)) {
            array_unshift($profiles, 'default');
        }

        return new JsonResponse($profiles);
    }
698197
public function getAll()
    {
        $result = [
            self::ENTRY_ID           => $this->_id,
            self::ENTRY_NAME         => $this->_name,
            self::ENTRY_WAIT_SYNC    => $this->_waitForSync,
            self::ENTRY_JOURNAL_SIZE => $this->_journalSize,
            self::ENTRY_IS_SYSTEM    => $this->_isSystem,
            self::ENTRY_IS_VOLATILE  => $this->_isVolatile,
            self::ENTRY_TYPE         => $this->_type,
            self::ENTRY_STATUS       => $this->_status,
            self::ENTRY_KEY_OPTIONS  => $this->_keyOptions
        ];

        if (null !== $this->_numberOfShards) {
            $result[self::ENTRY_NUMBER_OF_SHARDS] = $this->_numberOfShards;
        }
        
        if (null !== $this->_replicationFactor) {
            $result[self::ENTRY_REPLICATION_FACTOR] = $this->_replicationFactor;
        }
        
        if (null !== $this->_shardingStrategy) {
            $result[self::ENTRY_SHARDING_STRATEGY] = $this->_shardingStrategy;
        }

        if (is_array($this->_shardKeys)) {
            $result[self::ENTRY_SHARD_KEYS] = $this->_shardKeys;
        }

        return $result;
    }
1223761
public function getSurveyAnswerModel(\Gems_Tracker_Survey $survey, $language = null, $sourceSurveyId = null)
    {
        static $cache = array();        // working with 'real' cache produces out of memory error

        if (null === $sourceSurveyId) {
            $sourceSurveyId = $this->_getSid($survey->getSurveyId());
        }
        $language = $this->_getLanguage($sourceSurveyId, $language);
        $cacheId  = $sourceSurveyId . strtr($language, '-.', '__');

        if (!array_key_exists($cacheId, $cache)) {
            $model           = $this->tracker->getSurveyModel($survey, $this);
            $fieldMap        = $this->_getFieldMap($sourceSurveyId, $language)->applyToModel($model);
            $cache[$cacheId] = $model;
        }

        return $cache[$cacheId];
    }
1189278
public function getPersonalPolls()
    {
        $data = [
            'fullList' => 'true',
            'locale' => $this->locale,
            'token' => $this->token,
        ];
        $response = $this->doGet('/np/users/me/dashboard/myPolls', $data);

        if (strpos($response, '<title>Doodle: Not found') !== false) {
            throw new \Causal\DoodleClient\Exception\UnauthenticatedException('Doodle returned an error while fetching polls. Either you are not authenticated or your token is considered to be outdated.', 1454323881);
        }
        $polls = json_decode($response, true);

        $objects = [];
        if (!empty($polls['myPolls']['myPolls'])) {
            foreach ($polls['myPolls']['myPolls'] as $poll) {
                $objects[] = $this->pollRepository->create($poll);
            }
        }

        return $objects;
    }
1013291
static public function getStatuses()
    {
        return [
            self::STATUS_NEW => \Yii::t('skeeks/reviews2', "New"),
            self::STATUS_PROCESSED => \Yii::t('skeeks/reviews2', "In Progress"),
            self::STATUS_ALLOWED => \Yii::t('skeeks/reviews2', "Approved"),
            self::STATUS_CANCELED => \Yii::t('skeeks/reviews2', "Rejected"),
        ];
    }
390110
private function getAggregations()
    {
        $aggs = [];

        foreach ($this->aggregationProviders as $aggregationProvider) {
            $aggs[] = $aggregationProvider->getAggregation();
        }

        return $aggs;
    }
90073
protected function _getSourceSurveysForSynchronisation()
    {
        // Surveys in LS
        $lsDb = $this->getSourceDatabase();

        $select = $lsDb->select();
        $select->from($this->_getSurveysTableName(), 'sid')
                ->order('sid');

        return $lsDb->fetchCol($select);
    }
683390
public function toSurveyAction()
    {
        if (! $this->_initToken()) {
            // Default option
            $this->_forward('index');
            return;
        }

        $language = $this->locale->getLanguage();

        try {
            $url  = $this->token->getUrl(
                    $language,
                    $this->currentUser->getUserId() ? $this->currentUser->getUserId() : $this->token->getRespondentId()
                    );

            /************************
             * Optional user logout *
             ************************/
            if ($this->currentUser->isLogoutOnSurvey()) {
                $this->currentUser->unsetAsCurrentUser();
            }

            // Redirect at once
            header('Location: ' . $url);
            exit();

        } catch (\Gems_Tracker_Source_SurveyNotFoundException $e) {
            $this->addMessage(sprintf(
                    $this->_('The survey for token %s is no longer active.'),
                    strtoupper($this->tokenId)
                    ));

            // Default option
            $this->_forward('index');
        }
    }
695369
public function all()
    {
        $res = [];
        $len = count($this->fragments);

        for ($index=0; $index < $len; $index++) {
            $res[] = $this->get($index);
        }

        return $res;
    }
1326423
public function getAllRDFaDeliveries()
    {
        $aRDFaDeliveries = [];
        $aAssignedRDFaDeliveries = $this->getAssignedRDFaDeliveries();
        foreach ($this->_aRDFaDeliveries as $sName => $iType) {
            $oDelivery = new stdClass();
            $oDelivery->name = $sName;
            $oDelivery->type = $iType;
            $oDelivery->checked = in_array($sName, $aAssignedRDFaDeliveries);
            $aRDFaDeliveries[] = $oDelivery;
        }

        return $aRDFaDeliveries;
    }