<commit_before><?php
/**
 * Created by PhpStorm.
 * User: jjuszkiewicz
 * Date: 24.06.2014
 * Time: 10:02
 */

namespace Nokaut\ApiKit\Repository;


use Nokaut\ApiKit\ClientApi\ClientApiInterface;
use Nokaut\ApiKit\ClientApi\Rest\Fetch\Fetch;
use Nokaut\ApiKit\ClientApi\Rest\Fetch\ProductFetch;
use Nokaut\ApiKit\ClientApi\Rest\Fetch\ProductsFetch;
use Nokaut\ApiKit\ClientApi\Rest\Query\Sort;
use Nokaut\ApiKit\ClientApi\Rest\Query\Filter;
use Nokaut\ApiKit\Collection\Products;
use Nokaut\ApiKit\Config;
use Nokaut\ApiKit\Converter\ProductsWithBestOfferConverter;
use Nokaut\ApiKit\Entity\Product;
use Nokaut\ApiKit\ClientApi\Rest\Query\ProductQuery;
use Nokaut\ApiKit\ClientApi\Rest\Query\ProductsQuery;
use Nokaut\ApiKit\Converter\ProductConverter;
use Nokaut\ApiKit\Converter\ProductsConverter;
use Nokaut\ApiKit\Entity\ProductWithBestOffer;

class ProductsRepository extends RepositoryAbstract
{

    public static $fieldsForProductBox = array(
        'id', 'url', 'product_id', 'title', 'prices', 'offer_count', 'shop_count', 'category_id', 'offer_id',
        'url_original', 'offer_shop_id', 'shop_name', 'shop_url', 'top_category_id', 'top_position', 'photo_id',
        'click_url', 'click_value', 'shop', 'shop.url_logo', 'shop.name'
    );

    public static $fieldsWithBestOfferForProductBox = array(
        'id', 'url', 'product_id', 'title', 'prices', 'offer_count', 'shop_count', 'category_id', 'offer_id',
        'url_original', 'offer_shop_id', 'shop_name', 'shop_url', 'top_category_id', 'top_position', 'photo_id',
        'offer_with_minimum_price,offer_with_minimum_price.click_url', 'offer_with_minimum_price.price',
        'offer_with_minimum_price.id', 'producer_name'
    );

    public static $fieldsForProductPage = array(
        'id', 'url', 'category_id', 'description_html', 'id', 'prices',
        'is_with_photo', 'photo_id', 'producer_name', 'product_type_id', 'source', 'source_id', 'title', 'title_normalized',
        'properties', 'photo_ids', 'block_adsense', 'movie', 'rating'
    );

    public static $fieldsForList = array(
        'id', 'product_id', 'title', 'prices', 'offer_count', 'url', 'shop', 'shop.url_logo', 'shop_count', 'category_id',
        'offer_id', 'click_url', 'click_value', 'url_original', 'producer_name', 'offer_shop_id', 'shop.name', 'shop_url',
        'shop_id', 'top_category_id', 'top_position', 'photo_id', 'description_html', 'properties', '_metadata.url',
        '_metadata.block_adsense', 'offer', 'block_adsense', '_metadata.urls', '_metadata.paging', '_metadata.sorts',
        '_metadata.canonical','_phrase.value', '_phrase.url_out', '_phrase.url_category_template', '_phrase.url_in_template'
    );

    public static $fieldsForSimilarProductsInProductPage = array(
        'id', 'url', 'title', 'prices', 'photo_id', 'description_html', 'properties'
    );


    /**
     * @param int $limit
     * @param $fields
     * @return Products
     */
    public function fetchProducts($limit, array $fields)
    {
        $query = $this->prepareQueryForFetchProducts($limit, $fields);
        $fetch = new ProductsFetch($query, $this->cache);
        $this->clientApi->send($fetch);

        return $fetch->getResult();
    }<commit_msg>fix add fields for fieldsForSimilarProductsInProductPage<commit_after><?php
/**
 * Created by PhpStorm.
 * User: jjuszkiewicz
 * Date: 24.06.2014
 * Time: 10:02
 */

namespace Nokaut\ApiKit\Repository;


use Nokaut\ApiKit\ClientApi\ClientApiInterface;
use Nokaut\ApiKit\ClientApi\Rest\Fetch\Fetch;
use Nokaut\ApiKit\ClientApi\Rest\Fetch\ProductFetch;
use Nokaut\ApiKit\ClientApi\Rest\Fetch\ProductsFetch;
use Nokaut\ApiKit\ClientApi\Rest\Query\Sort;
use Nokaut\ApiKit\ClientApi\Rest\Query\Filter;
use Nokaut\ApiKit\Collection\Products;
use Nokaut\ApiKit\Config;
use Nokaut\ApiKit\Converter\ProductsWithBestOfferConverter;
use Nokaut\ApiKit\Entity\Product;
use Nokaut\ApiKit\ClientApi\Rest\Query\ProductQuery;
use Nokaut\ApiKit\ClientApi\Rest\Query\ProductsQuery;
use Nokaut\ApiKit\Converter\ProductConverter;
use Nokaut\ApiKit\Converter\ProductsConverter;
use Nokaut\ApiKit\Entity\ProductWithBestOffer;

class ProductsRepository extends RepositoryAbstract
{

    public static $fieldsForProductBox = array(
        'id', 'url', 'product_id', 'title', 'prices', 'offer_count', 'shop_count', 'category_id', 'offer_id',
        'url_original', 'offer_shop_id', 'shop_name', 'shop_url', 'top_category_id', 'top_position', 'photo_id',
        'click_url', 'click_value', 'shop', 'shop.url_logo', 'shop.name'
    );

    public static $fieldsWithBestOfferForProductBox = array(
        'id', 'url', 'product_id', 'title', 'prices', 'offer_count', 'shop_count', 'category_id', 'offer_id',
        'url_original', 'offer_shop_id', 'shop_name', 'shop_url', 'top_category_id', 'top_position', 'photo_id',
        'offer_with_minimum_price,offer_with_minimum_price.click_url', 'offer_with_minimum_price.price',
        'offer_with_minimum_price.id', 'producer_name'
    );

    public static $fieldsForProductPage = array(
        'id', 'url', 'category_id', 'description_html', 'id', 'prices',
        'is_with_photo', 'photo_id', 'producer_name', 'product_type_id', 'source', 'source_id', 'title', 'title_normalized',
        'properties', 'photo_ids', 'block_adsense', 'movie', 'rating'
    );

    public static $fieldsForList = array(
        'id', 'product_id', 'title', 'prices', 'offer_count', 'url', 'shop', 'shop.url_logo', 'shop_count', 'category_id',
        'offer_id', 'click_url', 'click_value', 'url_original', 'producer_name', 'offer_shop_id', 'shop.name', 'shop_url',
        'shop_id', 'top_category_id', 'top_position', 'photo_id', 'description_html', 'properties', '_metadata.url',
        '_metadata.block_adsense', 'offer', 'block_adsense', '_metadata.urls', '_metadata.paging', '_metadata.sorts',
        '_metadata.canonical','_phrase.value', '_phrase.url_out', '_phrase.url_category_template', '_phrase.url_in_template'
    );

    public static $fieldsForSimilarProductsInProductPage = array(
        'id', 'url', 'title', 'prices', 'photo_id', 'description_short', 'properties'
    );


    /**
     * @param int $limit
     * @param $fields
     * @return Products
     */
    public function fetchProducts($limit, array $fields)
    {
        $query = $this->prepareQueryForFetchProducts($limit, $fields);
        $fetch = new ProductsFetch($query, $this->cache);
        $this->clientApi->send($fetch);

        return $fetch->getResult();
    }
{'fraction_non_alphanumeric': 0.15448658649398705, 'fraction_numerical': 0.0037002775208140612, 'mean_word_length': 4.797140303842717, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1351250', 'n_tokens_mistral': 2229, 'n_tokens_neox': 2135, 'n_words': 384}