Allow producer to be executed only for a given user

master
Frederic Guillot 6 years ago
parent 99225f53b3
commit 4ab9ca165c
  1. 8
      app/models/user.php
  2. 14
      producer.php

@ -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')

@ -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…
Cancel
Save