<commit_before><?php

namespace Minds\Core\Boost\Network;

use Minds\Core;
use Minds\Core\Data;

class Expire
{
    protected $boost;
    protected $mongo;

    public function __construct(Data\Interfaces\ClientInterface $mongo = null)
    {
        $this->mongo = $mongo ?: Data\Client::build('MongoDB');

    }

    public function setBoost($boost)
    {
        $this->boost = $boost;
    }

    /**
     * Expire a boost from the queue
     * @return bool
     */
    public function expire()
    {
        if (!$this->boost) {
            return false;
        }

//        $handler = Core\Boost\Factory::build($this->getBoostHandler());
//        if (method_exists($handler, 'expireBoost')) {
//            $handler->expireBoost($this->boost);
//            return true;
//        }
//        return false;


        if ($this->boost->getState() == 'completed') {
            return true; //already completed
        }

        $this->boost->setState('completed')
            ->save();

        $this->mongo->remove("boost", ['_id' => $this->boost->getId()]);

        Core\Events\Dispatcher::trigger('notification', 'boost', [
            'to' => [$this->boost->getOwner()->guid],
            'from' => 100000000000000519,
            'entity' => $this->boost->getEntity(),
            'title' => $this->boost->getEntity()->title,
            'notification_view' => 'boost_completed',
            'params' => ['impressions' => $this->boost->getBid()],
            'impressions' => $this->boost->getBid()
        ]);
    }
}<commit_msg>(feat): return impressions vs bid<commit_after><?php

namespace Minds\Core\Boost\Network;

use Minds\Core;
use Minds\Core\Data;

class Expire
{
    protected $boost;
    protected $mongo;

    public function __construct(Data\Interfaces\ClientInterface $mongo = null)
    {
        $this->mongo = $mongo ?: Data\Client::build('MongoDB');

    }

    public function setBoost($boost)
    {
        $this->boost = $boost;
    }

    /**
     * Expire a boost from the queue
     * @return bool
     */
    public function expire()
    {
        if (!$this->boost) {
            return false;
        }

//        $handler = Core\Boost\Factory::build($this->getBoostHandler());
//        if (method_exists($handler, 'expireBoost')) {
//            $handler->expireBoost($this->boost);
//            return true;
//        }
//        return false;


        if ($this->boost->getState() == 'completed') {
            return true; //already completed
        }

        $this->boost->setState('completed')
            ->save();

        $this->mongo->remove("boost", ['_id' => $this->boost->getId()]);

        Core\Events\Dispatcher::trigger('notification', 'boost', [
            'to' => [$this->boost->getOwner()->guid],
            'from' => 100000000000000519,
            'entity' => $this->boost->getEntity(),
            'title' => $this->boost->getEntity()->title,
            'notification_view' => 'boost_completed',
            'params' => ['impressions' => $this->boost->getBid()],
            'impressions' => $this->boost->getImpressions()
        ]);
    }
}
{'fraction_non_alphanumeric': 0.17834190231362468, 'fraction_numerical': 0.011568123393316195, 'mean_word_length': 2.085232903865213, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 75, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '6512887', 'n_tokens_mistral': 980, 'n_tokens_neox': 924, 'n_words': 164}