<commit_before><?php
/**
 * Elasticsearch repository for Boost
 */
namespace Minds\Core\Boost\Network;

use Minds\Common\Repository\Response;
use Minds\Core\Di\Di;
use Minds\Core\Data\ElasticSearch\Prepared;

class ElasticRepository
{
    /** @var Client $es */
    protected $es;

    public function __construct($es = null)
    {
        $this->es = $es ?: Di::_()->get('Database\ElasticSearch');
    }

    /**
     * Return a list of boosts
     * @param array $opts
     * @return Response
     */
    public function getList($opts = [])
    {
        $opts = array_merge([
            'rating' => 3,
            'token' => 0,
        ], $opts);
        
        $must = [];
        $must_not = [];
        $sort = [ '@timestamp' => 'asc' ];

        $must[] = [
            'terms' => [
                'bid_type' => ['offchain','onchain'],
            ],
        ];

        $must[] = [
            'term' => [
                'type' => $opts['type'],
            ],
        ];

        if ($opts['state'] === 'approved') {
            $must[] = [
                'exists' => [
                    'field' => '@reviewed',
                ],
            ];
            $must[] = [
                'range' => [
                    'rating' => [
                        'lte' => $opts['rating'],
                    ],
                ],
            ];
        }

        if ($opts['state'] === 'review') {
            $must_not[] = [
                'exists' => [
                    'field' => '@reviewed',
                ],
            ];
            $sort = [ '@timestamp' => 'asc' ];<commit_msg>(chore): use bid_type tokens vs offchain and onchain|<commit_after><?php
/**
 * Elasticsearch repository for Boost
 */
namespace Minds\Core\Boost\Network;

use Minds\Common\Repository\Response;
use Minds\Core\Di\Di;
use Minds\Core\Data\ElasticSearch\Prepared;

class ElasticRepository
{
    /** @var Client $es */
    protected $es;

    public function __construct($es = null)
    {
        $this->es = $es ?: Di::_()->get('Database\ElasticSearch');
    }

    /**
     * Return a list of boosts
     * @param array $opts
     * @return Response
     */
    public function getList($opts = [])
    {
        $opts = array_merge([
            'rating' => 3,
            'token' => 0,
        ], $opts);
        
        $must = [];
        $must_not = [];
        $sort = [ '@timestamp' => 'asc' ];

        $must[] = [
            'term' => [
                'bid_type' => 'tokens',
            ],
        ];

        $must[] = [
            'term' => [
                'type' => $opts['type'],
            ],
        ];

        if ($opts['state'] === 'approved') {
            $must[] = [
                'exists' => [
                    'field' => '@reviewed',
                ],
            ];
            $must[] = [
                'range' => [
                    'rating' => [
                        'lte' => $opts['rating'],
                    ],
                ],
            ];
        }

        if ($opts['state'] === 'review') {
            $must_not[] = [
                'exists' => [
                    'field' => '@reviewed',
                ],
            ];
            $sort = [ '@timestamp' => 'asc' ];
{'fraction_non_alphanumeric': 0.17650695517774342, 'fraction_numerical': 0.0012364760432766616, 'mean_word_length': 1.1631016042780749, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, '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': '809563', 'n_tokens_mistral': 956, 'n_tokens_neox': 912, 'n_words': 171}