Merge branch '0.8.x' of git@gitorious.org:laconica/mainline into 0.8.x

This commit is contained in:
Sarven Capadisli 2009-07-24 15:06:07 +00:00
commit bb2186527a
5 changed files with 13 additions and 8 deletions

View File

@ -59,7 +59,7 @@ class Fave extends Memcached_DataObject
$qry = 'SELECT fave.* FROM fave '; $qry = 'SELECT fave.* FROM fave ';
$qry .= 'INNER JOIN notice ON fave.notice_id = notice.id '; $qry .= 'INNER JOIN notice ON fave.notice_id = notice.id ';
$qry .= 'WHERE fave.user_id = ' . $user_id . ' '; $qry .= 'WHERE fave.user_id = ' . $user_id . ' ';
$qry .= 'AND notice.is_local != ' . NOTICE_GATEWAY . ' '; $qry .= 'AND notice.is_local != ' . Notice::GATEWAY . ' ';
} }
if ($since_id != 0) { if ($since_id != 0) {

View File

@ -32,7 +32,6 @@ define('NOTICE_CACHE_WINDOW', 61);
define('NOTICE_LOCAL_PUBLIC', 1); define('NOTICE_LOCAL_PUBLIC', 1);
define('NOTICE_REMOTE_OMB', 0); define('NOTICE_REMOTE_OMB', 0);
define('NOTICE_LOCAL_NONPUBLIC', -1); define('NOTICE_LOCAL_NONPUBLIC', -1);
define('NOTICE_GATEWAY', -2);
define('MAX_BOXCARS', 128); define('MAX_BOXCARS', 128);
@ -63,6 +62,8 @@ class Notice extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */ /* the code above is auto generated do not remove the tag below */
###END_AUTOCODE ###END_AUTOCODE
const GATEWAY = -2;
function getProfile() function getProfile()
{ {
return Profile::staticGet('id', $this->profile_id); return Profile::staticGet('id', $this->profile_id);

View File

@ -443,7 +443,7 @@ class User extends Memcached_DataObject
'SELECT notice.* ' . 'SELECT notice.* ' .
'FROM notice JOIN subscription ON notice.profile_id = subscription.subscribed ' . 'FROM notice JOIN subscription ON notice.profile_id = subscription.subscribed ' .
'WHERE subscription.subscriber = %d ' . 'WHERE subscription.subscriber = %d ' .
'AND notice.is_local != ' . NOTICE_GATEWAY; 'AND notice.is_local != ' . Notice::GATEWAY;
return Notice::getStream(sprintf($qry, $this->id), return Notice::getStream(sprintf($qry, $this->id),
'user:notices_with_friends:' . $this->id, 'user:notices_with_friends:' . $this->id,
$offset, $limit, $since_id, $before_id, $offset, $limit, $since_id, $before_id,

View File

@ -22,7 +22,6 @@
* @category QueueManager * @category QueueManager
* @package Laconica * @package Laconica
* @author Evan Prodromou <evan@controlyourself.ca> * @author Evan Prodromou <evan@controlyourself.ca>
* @author Sarven Capadisli <csarven@controlyourself.ca>
* @copyright 2009 Control Yourself, Inc. * @copyright 2009 Control Yourself, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://laconi.ca/ * @link http://laconi.ca/
@ -86,10 +85,14 @@ class DBQueueManager extends QueueManager
$start = time(); $start = time();
$result = null; $result = null;
$sleeptime = 1;
do { do {
$qi = Queue_item::top($queue); $qi = Queue_item::top($queue);
if (empty($qi)) { if (empty($qi)) {
sleep(1); $this->_log(LOG_DEBUG, "No new queue items, sleeping $sleeptime seconds.");
sleep($sleeptime);
$sleeptime *= 2;
} else { } else {
$notice = Notice::staticGet('id', $qi->notice_id); $notice = Notice::staticGet('id', $qi->notice_id);
if (!empty($notice)) { if (!empty($notice)) {
@ -100,6 +103,7 @@ class DBQueueManager extends QueueManager
$qi->free(); $qi->free();
$qi = null; $qi = null;
} }
$sleeptime = 1;
} }
} while (empty($result) && (is_null($timeout) || (time() - $start) < $timeout)); } while (empty($result) && (is_null($timeout) || (time() - $start) < $timeout));

View File

@ -330,7 +330,7 @@ class TwitterStatusFetcher extends Daemon
$notice->rendered = common_render_content($notice->content, $notice); $notice->rendered = common_render_content($notice->content, $notice);
$notice->source = 'twitter'; $notice->source = 'twitter';
$notice->reply_to = null; // XXX lookup reply $notice->reply_to = null; // XXX lookup reply
$notice->is_local = NOTICE_GATEWAY; $notice->is_local = Notice::GATEWAY;
if (Event::handle('StartNoticeSave', array(&$notice))) { if (Event::handle('StartNoticeSave', array(&$notice))) {
$id = $notice->insert(); $id = $notice->insert();