forked from dysosmus/miniflux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
producer.php
39 lines (30 loc) · 908 Bytes
/
producer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
use Pheanstalk\Pheanstalk;
use Miniflux\Model;
require __DIR__.'/app/common.php';
if (php_sapi_name() !== 'cli') {
die('This script can run only from the command line.'.PHP_EOL);
}
$options = getopt('', array(
'limit::',
'user::',
));
$limit = get_cli_option('limit', $options);
$user_id = get_cli_option('user', $options);
$connection = new Pheanstalk(BEANSTALKD_HOST);
if ($user_id) {
$user_ids = array($user_id);
} else {
$user_ids = Model\User\get_all_user_ids();
}
foreach ($user_ids as $user_id) {
foreach (Model\Feed\get_feed_ids_to_refresh($user_id, $limit) as $feed_id) {
$payload = serialize(array(
'feed_id' => $feed_id,
'user_id' => $user_id,
));
$connection
->useTube(BEANSTALKD_QUEUE)
->put($payload, Pheanstalk::DEFAULT_PRIORITY, Pheanstalk::DEFAULT_DELAY, BEANSTALKD_TTL);
}
}