Get the top tag IDs.

@param array    $sourceIds
@param int|null $limit
@param bool     $withCount

@return array
506300
public function getTopTagIds(array $sourceIds = [], int $limit = null, bool $withCount = false): array
    {
        /** @var Model $model */
        $model = $this->framework->getAdapter(Model::class);

        $tagIds = $model->getRelatedValues($this->sourceTable, $this->sourceField, $sourceIds);
        $tagIds = \array_map('intval', $tagIds);

        if (0 === \count($tagIds)) {
            return [];
        }

        $helper = [];

        // Create the helper array with tag occurrences
        foreach ($tagIds as $tagId) {
            ++$helper[$tagId];
        }

        // Sort the helper array descending
        \arsort($helper);

        // Strip the count data
        if (!$withCount) {
            $helper = \array_keys($helper);
        }

        return \array_slice($helper, 0, $limit, $withCount);
    }
658828
static public function fetchByParentID( $parentID, $offset = 0, $limit = null, $mainTranslation = false )
    {
        if ( $offset === 0 && $limit === null )
        {
            $limits = null;
        }
        else
        {
            $limits = array( 'offset' => $offset, 'limit' => $limit );
        }
        return self::fetchList(
            array( 'parent_id' => $parentID, 'main_tag_id' => 0 ),
            $limits,
            null,
            $mainTranslation
        );
    }
187436
private function getSitesFromIds($idSites, $limit = false)
    {
        $sites = $this->getModel()->getSitesFromIds($idSites, $limit);

        foreach ($sites as &$site) {
            $this->enrichSite($site);
        }

        $sites = Site::setSitesFromArray($sites);

        return $sites;
    }
534238
public function getRelatedFAQs($limit = null)
    {
        $tags = $this->owner->Tags();

        if ($tags->count() == 0) {
            return null;
        }

        // find any FAQ that has one of the same tags
        $faqs = FAQ::get()
            ->innerJoin('FAQ_Tags', '"FAQ"."ID" = "FAQ_Tags"."FAQID"')
            ->where(sprintf('"FAQ_Tags"."TaxonomyTermID" IN (%s)', implode(',', $tags->column('ID'))))
            ->exclude('ID', $this->owner->ID);

        // limit the faqs if applicable
        if ($limit && is_int($limit)) {
            $faqs = $faqs->limit($limit);
        }

        return $faqs;
    }
1368866
protected function _filterAnswersOnly($sourceSurveyId, array $answers)
    {
        $s = $sourceSurveyId . 'X';
        $l = strlen($s);

        $results = array();
        foreach ($answers as $key => $value) {
            if (substr($key, 0, $l) == $s) {
                $results[$key] = $value;
            }
        }

        return $results;
    }
682780
public function getSurveyInfo($sourceSurveyId)
    {
        $db = $this->getSourceDatabase();

        $select = $db->select();
        $select->from('gems__openrosaforms')
            ->where('gof_id = ?', $sourceSurveyId);

        return $db->fetchRow($select);
    }
199510
public static function forSource(TagSource $source, SS_List $items = null)
    {
        // Create Data List:
        
        $tags = DataList::create(static::class);
        
        // Filter Tagged Items:
        
        if ($items instanceof DataList) {
            
            if (!$items->exists()) {
                return ArrayList::create();
            }
            
            if ($belongs = Config::inst()->get(static::class, 'belongs_many_many')) {
                
                // Filter Tags Associated with Items:
                
                if ($component = array_search($items->dataClass(), $belongs)) {
                    $tags = $tags->filter(sprintf('%s.ID', $component), $items->column('ID'));
                }
                
            }
            
        }
        
        // Convert List to Array:
        
        $tags = $tags->toArray();
        
        // Associate Tags with Source:
        
        foreach ($tags as $tag) {
            $tag->setSource($source);
        }
        
        // Answer Array List:
        
        return ArrayList::create($tags);
    }
1104313
public static function search(
        Client $client,
        array $tags,
        int $page,
        int $limit = 20
    ): array {
        if (!self::isValidPageNumber($page)) {
            throw new InvalidArgumentException('Page number should be greater than zero');
        }

        if (!self::isValidLimitation($page)) {
            throw new InvalidArgumentException('Limit should be greater than zero');
        }

        $query = [
            'page' => $page,
            'limit' => $limit,
            'tags' => implode(',', $tags),
        ];

        $postsAsArrays = $client->sendRequest(
            self::ENDPOINT,
            $query
        );

        return array_map(function (array $post) use ($client): self {
            return self::fromArray($client, $post);
        }, $postsAsArrays);
    }
461689
public function listTags($seriesId, $submissionId, $optParams = array()) {
      $params = array('seriesId' => $seriesId, 'submissionId' => $submissionId);
      $params = array_merge($params, $optParams);
      $data = $this->__call('list', array($params));
      if ($this->useObjects()) {
        return new TagList($data);
      } else {
        return $data;
      }
    }
139058
public function getChildrenCount($tagId, array $translations = null, $useAlwaysAvailable = true)
    {
        $query = $this->createTagCountQuery($translations, $useAlwaysAvailable);
        $query->where(
            $query->expr->lAnd(
                $query->expr->eq(
                    $this->handler->quoteColumn('parent_id', 'eztags'),
                    $query->bindValue($tagId, null, PDO::PARAM_INT)
                ),
                $query->expr->eq($this->handler->quoteColumn('main_tag_id', 'eztags'), 0)
            )
        );

        $statement = $query->prepare();
        $statement->execute();

        $rows = $statement->fetchAll(PDO::FETCH_ASSOC);

        return (int) $rows[0]['count'];
    }
1173358
protected function getValuesById($valueIds, $attrOnly = [])
    {
        $recursionKey = $this->getMetaModel()->getTableName();

        // Prevent recursion.
        static $tables = [];
        if (isset($tables[$recursionKey])) {
            return [];
        }
        $tables[$recursionKey] = $recursionKey;

        $metaModel = $this->getSelectMetaModel();
        $filter    = $metaModel->getEmptyFilter()->addFilterRule(new StaticIdList($valueIds));
        $items     = $metaModel->findByFilter($filter, 'id', 0, 0, 'ASC', $attrOnly);
        unset($tables[$recursionKey]);

        return $this->itemsToValues($items);
    }
339176
final public static function count(array $criteria = [], bool $withTrash = false)
    {
        $criteria = self::criteriaWithSoftDelete($criteria, $withTrash);
        return static::getRepository()
            ->count($criteria);
    }
1214721
public function listPerPage($attributeCode, $limit = 10, $withCount = false, array $queryParameters = []): AkeneoResourcePageInterface
    {
        $page = $this->akeneoPimClient
            ->getAttributeOptionApi()
            ->listPerPage($attributeCode, $limit, $withCount, $queryParameters);

        return $this->wrapperFactory
            ->createAkeneoPage($page);
    }
806489
public function getTokenInfo(\Gems_Tracker_Token $token, $surveyId, $sourceSurveyId, array $fields = null)
    {
        if (! $token->cacheHas(self::CACHE_TOKEN_INFO)) {
            if (null === $sourceSurveyId) {
                $sourceSurveyId = $this->_getSid($surveyId);
            }

            $lsTokens = $this->_getTokenTableName($sourceSurveyId);
            $tokenId  = $this->_getToken($token->getTokenId());

            $sql = 'SELECT *
                FROM ' . $lsTokens . '
                WHERE token = ? LIMIT 1';

            try {
                $result = $this->getSourceDatabase()->fetchRow($sql, $tokenId);
            } catch (\Zend_Db_Statement_Exception $exception) {
                $this->logger->logError($exception, $this->request);
                $result = false;
            }

            $token->cacheSet(self::CACHE_TOKEN_INFO, $result);
        } else {
            $result = $token->cacheGet(self::CACHE_TOKEN_INFO);
        }

        if ($fields !== null) $result = array_intersect_key((array) $result, array_flip($fields));

        return $result;
    }
508914
def get_top_tags(self, limit=None, cacheable=True):
        """"""

        # Last.fm has no "limit" parameter for tag.getTopTags
        # so we need to get all (250) and then limit locally
        doc = _Request(self, "tag.getTopTags").execute(cacheable)

        seq = []
        for node in doc.getElementsByTagName("tag"):
            if limit and len(seq) >= limit:
                break
            tag = Tag(_extract(node, "name"), self)
            weight = _number(_extract(node, "count"))
            seq.append(TopItem(tag, weight))

        return seq
518428
def get_top_tags(self, limit=None):
        """"""

        doc = self._request(self.ws_prefix + ".getTopTags", True)

        elements = doc.getElementsByTagName("tag")
        seq = []

        for element in elements:
            tag_name = _extract(element, "name")
            tagcount = _extract(element, "count")

            seq.append(TopItem(Tag(tag_name, self.network), tagcount))

        if limit:
            seq = seq[:limit]

        return seq
855327
public function list(int $beginId = 0, int $limit = 50, string $status = 'CHECKING')
    {
        $params = [
            'begin_id' => $beginId,
            'limit' => $limit,
            'status' => $status,
        ];

        return $this->httpPostJson('card/submerchant/batchget', $params);
    }