From ce92bc71431ec878c391b1ac6e16fd59cafd50b1 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 11 Mar 2010 11:01:01 -0800 Subject: Drop timestamp cutoff parameter from User::getCurrentNotice() and Profile::getCurrentNotice(). It's not currently used, and won't be efficient when we update the notice.profile_id_idx index to optimize for our id-based sorting when pulling user post lists for profile pages, feeds etc. --- classes/Profile.php | 12 +++++++----- classes/User.php | 9 +++++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/classes/Profile.php b/classes/Profile.php index 0322c9358..91f6e4692 100644 --- a/classes/Profile.php +++ b/classes/Profile.php @@ -147,14 +147,16 @@ class Profile extends Memcached_DataObject return ($this->fullname) ? $this->fullname : $this->nickname; } - # Get latest notice on or before date; default now - function getCurrentNotice($dt=null) + /** + * Get the most recent notice posted by this user, if any. + * + * @return mixed Notice or null + */ + function getCurrentNotice() { $notice = new Notice(); $notice->profile_id = $this->id; - if ($dt) { - $notice->whereAdd('created < "' . $dt . '"'); - } + // @fixme change this to sort on notice.id only when indexes are updated $notice->orderBy('created DESC, notice.id DESC'); $notice->limit(1); if ($notice->find(true)) { diff --git a/classes/User.php b/classes/User.php index aa9fbf948..330da039b 100644 --- a/classes/User.php +++ b/classes/User.php @@ -132,13 +132,18 @@ class User extends Memcached_DataObject return !in_array($nickname, $blacklist); } - function getCurrentNotice($dt=null) + /** + * Get the most recent notice posted by this user, if any. + * + * @return mixed Notice or null + */ + function getCurrentNotice() { $profile = $this->getProfile(); if (!$profile) { return null; } - return $profile->getCurrentNotice($dt); + return $profile->getCurrentNotice(); } function getCarrier() -- cgit v1.2.3-54-g00ecf