summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorEvan Prodromou <evan@prodromou.name>2008-07-22 12:02:13 -0400
committerEvan Prodromou <evan@prodromou.name>2008-07-22 12:02:13 -0400
commit64ed01f0aff569da2fd4ed589df9ed4ee9852cb7 (patch)
treed385c10c3aef1408bf62fc9003bb2d697536e299 /classes
parentab1f2ff9d07088c7a3607ee6d05b1042d735960d (diff)
centralize and optimize with-friends query
darcs-hash:20080722160213-84dde-2e466b9cc4601a8cb7237770a7df17a2f9dcadb9.gz
Diffstat (limited to 'classes')
-rw-r--r--classes/User.php19
-rw-r--r--classes/stoica.links.ini3
2 files changed, 22 insertions, 0 deletions
diff --git a/classes/User.php b/classes/User.php
index e4928eb34..1772b82e0 100644
--- a/classes/User.php
+++ b/classes/User.php
@@ -128,4 +128,23 @@ class User extends DB_DataObject
return true;
}
+
+ function noticesWithFriends() {
+
+ $notice = new Notice();
+
+ $notice->selectAs();
+
+ $subscription = new Subscription();
+
+ $subscription->subscriber = $this->id;
+
+ $notice->joinAdd($subscription);
+ $notice->whereAdd('notice.profile_id = subscription.subscribed');
+ $notice->selectAs($subscription, 'sub_%');
+
+ $notice->orderBy('created DESC, notice.id DESC');
+
+ return $notice;
+ }
}
diff --git a/classes/stoica.links.ini b/classes/stoica.links.ini
index 7e4e3613c..bb849cbf2 100644
--- a/classes/stoica.links.ini
+++ b/classes/stoica.links.ini
@@ -34,3 +34,6 @@ user_id = user:id
[queue_item]
notice_id = notice:id
+[subscription]
+subscriber = profile:id
+subscribed = profile:id