<commit_before><?php

use Miniflux\Handler;
use Miniflux\Model;
use Pheanstalk\Pheanstalk;

require __DIR__.'/app/common.php';

if (php_sapi_name() !== 'cli') {
    die('This script can run only from the command line.'.PHP_EOL);
}

$connection = new Pheanstalk(BEANSTALKD_HOST);

while ($job = $connection->reserveFromTube(BEANSTALKD_QUEUE)) {
    $payload = unserialize($job->getData());

    echo 'Processing feed_id=', $payload['feed_id'], ' for user_id=', $payload['user_id'],PHP_EOL;

    Handler\Feed\update_feed($payload['user_id'], $payload['feed_id']);
    Model\Item\autoflush_read($payload['user_id']);
    Model\Item\autoflush_unread($payload['user_id']);
    Miniflux\Helper\write_debug_file();

    $connection->delete($job);
}
<commit_msg>Show processing time in worker<commit_after><?php

use Miniflux\Handler;
use Miniflux\Model;
use Pheanstalk\Pheanstalk;

require __DIR__.'/app/common.php';

if (php_sapi_name() !== 'cli') {
    die('This script can run only from the command line.'.PHP_EOL);
}

$connection = new Pheanstalk(BEANSTALKD_HOST);

while ($job = $connection->reserveFromTube(BEANSTALKD_QUEUE)) {
    $payload = unserialize($job->getData());
    $start_time = microtime(true);

    echo 'Processing feed_id=', $payload['feed_id'], ' for user_id=', $payload['user_id'];

    Handler\Feed\update_feed($payload['user_id'], $payload['feed_id']);
    Model\Item\autoflush_read($payload['user_id']);
    Model\Item\autoflush_unread($payload['user_id']);

    echo ', duration='.(microtime(true) - $start_time).' seconds', PHP_EOL;

    Miniflux\Helper\write_debug_file();
    $connection->delete($job);
}

{'fraction_non_alphanumeric': 0.1731123388581952, 'fraction_numerical': 0.0, 'mean_word_length': 5.546184738955823, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '1004102', 'n_tokens_mistral': 596, 'n_tokens_neox': 575, 'n_words': 95}