Allow producer to be executed only for a given user
This commit is contained in:
parent
99225f53b3
commit
4ab9ca165c
@ -104,6 +104,14 @@ function get_all_users()
|
||||
->findAll();
|
||||
}
|
||||
|
||||
function get_all_user_ids()
|
||||
{
|
||||
return Database::getInstance('db')
|
||||
->table(TABLE)
|
||||
->asc('id')
|
||||
->findAllByColumn('id');
|
||||
}
|
||||
|
||||
function get_user_by_id($user_id)
|
||||
{
|
||||
return Database::getInstance('db')
|
||||
|
14
producer.php
14
producer.php
@ -11,16 +11,24 @@ if (php_sapi_name() !== 'cli') {
|
||||
|
||||
$options = getopt('', array(
|
||||
'limit::',
|
||||
'user::',
|
||||
));
|
||||
|
||||
$limit = get_cli_option('limit', $options);
|
||||
$user_id = get_cli_option('user', $options);
|
||||
$connection = new Pheanstalk(BEANSTALKD_HOST);
|
||||
|
||||
foreach (Model\User\get_all_users() as $user) {
|
||||
foreach (Model\Feed\get_feed_ids_to_refresh($user['id'], $limit) as $feed_id) {
|
||||
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'],
|
||||
'user_id' => $user_id,
|
||||
));
|
||||
|
||||
$connection
|
||||
|
Loading…
Reference in New Issue
Block a user