notices and counts

darcs-hash:20080722162332-84dde-75801a271f50789377aa7a3467223286c372ec6c.gz
This commit is contained in:
Evan Prodromou 2008-07-22 12:23:32 -04:00
parent 97b1552c9a
commit 9515303b14
4 changed files with 9 additions and 19 deletions

View File

@ -78,11 +78,7 @@ class AllAction extends StreamAction {
$page = 1; $page = 1;
} }
$notice = $user->noticesWithFriends(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); list($cnt, $notice) = $user->noticesWithFriends(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
# XXX: revisit constant scope
$cnt = $notice->find();
if ($cnt > 0) { if ($cnt > 0) {
common_element_start('ul', array('id' => 'notices')); common_element_start('ul', array('id' => 'notices'));

View File

@ -43,11 +43,7 @@ class AllrssAction extends Rss10Action {
$user = $this->user; $user = $this->user;
$notice = $user->noticesWithFriends(0, $limit); list($cnt, $notice) = $user->noticesWithFriends(0, $limit);
# XXX: revisit constant scope
$cnt = $notice->find();
while ($notice->fetch()) { while ($notice->fetch()) {
$notices[] = clone($notice); $notices[] = clone($notice);

View File

@ -223,9 +223,7 @@ class TwitapistatusesAction extends TwitterapiAction {
$link = common_local_url('all', array('nickname' => $user->nickname)); $link = common_local_url('all', array('nickname' => $user->nickname));
$subtitle = sprintf(_("Updates from %s and friends on %s!"), $user->nickname, $sitename); $subtitle = sprintf(_("Updates from %s and friends on %s!"), $user->nickname, $sitename);
$notice->$user->noticesWithFriends(($page-1)*20, $count); list($cnt, $notice) = $user->noticesWithFriends(($page-1)*20, $count);
$cnt = $notice->find();
switch($apidata['content-type']) { switch($apidata['content-type']) {
case 'xml': case 'xml':

View File

@ -133,12 +133,12 @@ class User extends DB_DataObject
$notice = new Notice(); $notice = new Notice();
$notice->query('SELECT notice.* ' . $cnt = $notice->query('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 = ' . $this->id . ' ' . 'WHERE subscription.subscriber = ' . $this->id . ' ' .
'ORDER BY created DESC, notice.id DESC ' . 'ORDER BY created DESC, notice.id DESC ' .
'LIMIT ' . $offset . ', ' . $limit); 'LIMIT ' . $offset . ', ' . $limit);
return $notice; return array($cnt, $notice);
} }
} }