Find import results by import id and pending status.

@param \Cake\Datasource\QueryInterface $query Query object
@param mixed[] $options Additional options
@return \Cake\Datasource\QueryInterface
194099
public function findPending(QueryInterface $query, array $options) : QueryInterface
    {
        $query->where([
            'import_id' => $options['import']->id,
            'status' => static::STATUS_PENDING
        ]);

        return $query;
    }
986154
public function findSitemapRecords(Query $query, array $options) {
		$query = $query
			->where($this->_config['conditions'])
			->cache("sitemap_{$query->repository()->alias()}", $this->_config['cacheConfigKey'])
			->order($this->_config['order'])
			->formatResults(function ($results) {
				return $this->mapResults($results);
			});

		if (!empty($this->_config['fields'])) {
			$query = $query->select($this->_config['fields']);
		}

		return $query;
	}
918255
public function queryList($query, $options = array())
    {
        $statement = $this->_runQuery($query, $options);
        return $statement->fetch(\PDO::FETCH_NUM);
    }
1193907
public function findSlugForFilterData(Query $query, array $options)
    {
        if (!isset($options['request']) || get_class($options['request']) !== ServerRequest::class) {
            user_error('The request query option must exist and must be of type Cake\Http\ServerRequest.');
        }

        if (!isset($options['filterData'])) {
            user_error('No filterData option provided.');
        }

        /** @var ServerRequest $request */
        $request = $options['request'];
        $filterData = $options['filterData'];

        return $query
            ->select($this->getAlias() . '.slug')
            ->where([
                $this->getAlias() . '.controller' => $request->getParam('controller'),
                $this->getAlias() . '.action' => $request->getParam('action'),
                $this->getAlias() . '.filter_data' => $this->_encodeFilterData($filterData)
            ])
            ->where($this->_pluginCondition($request));
    }
151560
public function findSlugged(Query $query, array $options) {
		if (empty($options['slug'])) {
			throw new InvalidArgumentException("The 'slug' key is required for find('slugged')");
		}

		return $query->where([$this->_config['field'] => $options['slug']]);
	}
473412
protected function getPaginationData(Select $query, array $options)
    {
        // Get pagination options
        $page = (int) Arr::get($options, 'page');

        if ($page < 1) {
            $page = 1;
        }

        $resultsPerPage = Arr::get(
            $options,
            'resultsPerPage',
            $this->resultsPerPage
        );

        // Get total results
        $resultCount = $this->getQueryResultCount($query);
        $pageCount   = ceil($resultCount / $resultsPerPage);

        return new PaginationData([
            'page'             => $page,
            'page_count'       => $pageCount,
            'result_count'     => $resultCount,
            'results_per_page' => $resultsPerPage
        ]);
    }
962616
public function createSearch($query = '', $options = null, BuilderInterface $builder = null)
    {
        $search = new Search($this->getClient(), $builder);
        $search->addIndex($this);
        $search->setOptionsAndQuery($options, $query);

        return $search;
    }
512483
protected function _executeQuery(Query $query, array $options = [])
    {
        switch ($query->action()) {
            case Query::ACTION_CREATE:
                return $this->_executeCreateQuery($query, $options);
            case Query::ACTION_READ:
                return $this->_executeReadQuery($query, $options);
            case Query::ACTION_UPDATE:
                return $this->_executeUpdateQuery($query, $options);
            case Query::ACTION_DELETE:
                return $this->_executeDeleteQuery($query, $options);
        }

        return false;
    }
90438
public function search($query, $options = [])
    {
        $url = $this->instanceURLRepo->get();
        $url .= $this->resourceRepo->get('search');
        $url .= '?q=';
        $url .= urlencode($query);

        $searchResults = $this->request($url, $options);

        return $searchResults;
    }
974010
public function beforeFind(Event $event, Query $query, ArrayObject $options)
    {
        if (!$query->clause('order')) {
            $query->order([$this->_table->aliasField($this->_config['order']) => 'ASC']);
        }
    }
435642
public function findKv(Query $query, array $options)
    {
        return $query
            ->find('list', [
                'keyField' => 'path',
                'valueField' => 'value',
                'groupField' => 'namespace',
            ])
            ->formatResults(function ($results) {
                $resultSet = $results->toArray();
                if (isset($resultSet[''])) {
                    $resultSet += $resultSet[''];
                    unset($resultSet['']);
                }

                return $resultSet;
            });
    }
1096030
private static function applyOptions(QueryBuilder $query, array $options)
    {
        if (isset($options['orderby'])) {
            $option = $options['orderby'];
            foreach ($option as $column => $order) {
                $query = $query->orderBy($column, $order);
            }
        }

        if (isset($options['for_update']) && $options['for_update'] === true) {
            $query->forUpdate();
        } elseif (isset($options['shared_lock']) && $options['shared_lock'] === true) {
            $query->sharedLock();
        }

        $limit  = $options['limit'] ?? null;
        $offset = $options['offset'] ?? 0;

        if ($limit !== null) {
            $query = $query->limit($limit, $offset);
        }

        return $query;
    }
331947
public function search($query = '', $options = null)
    {
        $this->setOptionsAndQuery($options, $query);

        $query = $this->getQuery();
        $path = $this->getPath();

        $params = $this->getOptions();

        // Send scroll_id via raw HTTP body to handle cases of very large (> 4kb) ids.
        if ('_search/scroll' == $path) {
            $data = [self::OPTION_SCROLL_ID => $params[self::OPTION_SCROLL_ID]];
            unset($params[self::OPTION_SCROLL_ID]);
        } else {
            $data = $query->toArray();
        }

        $response = $this->getClient()->request(
            $path,
            Request::GET,
            $data,
            $params
        );

        return $this->_builder->buildResultSet($response, $query);
    }
803472
protected function whereBatchId($query, EntryQueryOptions $options)
    {
        $query->when($options->batchId, function ($query, $batchId) {
            return $query->where('batch_id', $batchId);
        });

        return $this;
    }
883875
public function handle(QueryInterface $query)
    {
        $files = $query->getFiles();

        return $this->extract(new FilesCollection($this->getFiles($files)));
    }
84915
public function getNativeQuery(Query $query, array $options = array())
    {
        // Clone the original SimpleExpression
        $statement = clone $query->getStatement();

        // Apply CustomVisitors to modify SimpleExpression
        $customVisitors = $this->getCustomVisitors();
        if($customVisitors) {
            $statement->dispatch($customVisitors);
        }

        // Apply OuterVisitor to output the nativeQuery from SimpleExpression
        $outerVisitor = $this->getOuterVisitor();
        $statement->dispatch($outerVisitor);
        
        // Get NativeQuery from the Visitor
        return $outerVisitor->getNativeQuery($options);
    }
839358
public function findFailed(QueryInterface $query, array $options) : QueryInterface
    {
        $query->where([
            'import_id' => $options['import']->id,
            'status' => static::STATUS_FAIL
        ]);

        return $query;
    }