]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
blow off DB_DataObject joins, write SQL from scratch
authorEvan Prodromou <evan@prodromou.name>
Tue, 22 Jul 2008 16:15:49 +0000 (12:15 -0400)
committerEvan Prodromou <evan@prodromou.name>
Tue, 22 Jul 2008 16:15:49 +0000 (12:15 -0400)
darcs-hash:20080722161549-84dde-fedeed101bdef172f4a7aabf2278f1a2277a6d88.gz

actions/all.php
actions/allrss.php
actions/twitapistatuses.php
classes/User.php

index 3d3d1c3563188b8c23e7cfc1e82f14f6b603b132..0f8cf587cd8a27943ff1a68790a2aeedcf63dbce 100644 (file)
@@ -78,11 +78,11 @@ class AllAction extends StreamAction {
                        $page = 1;
                }
                
-               $notice = $user->noticesWithFriends($page);
+               $notice = $user->noticesWithFriends(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
+                                                                                       
                # XXX: revisit constant scope
                
-               $notice->limit((($page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1);
-               
+               $cnt = $notice->find();
                
                if ($cnt > 0) {
                        common_element_start('ul', array('id' => 'notices'));
index a64b47641462494c15624ffe36a820f2d93b5759..b6701cfdc7e4d9f4bd87be81d90e6acdf2aca776 100644 (file)
@@ -43,13 +43,11 @@ class AllrssAction extends Rss10Action {
 
                $user = $this->user;
                
-               $notice = $user->noticesWithFriends();
+               $notice = $user->noticesWithFriends(0, $limit);
+                                                                                       
+               # XXX: revisit constant scope
                
-               if ($limit != 0) {
-                       $notice->limit(0, $limit);
-               }
-               
-               $notice->find();
+               $cnt = $notice->find();
 
                while ($notice->fetch()) {
                        $notices[] = clone($notice);
index 749f2f0849fb7f8d852bf0d60555524ff682ee65..56a8199b78c042ccbe054b2347ace6690b42e8dc 100644 (file)
@@ -223,9 +223,7 @@ class TwitapistatusesAction extends TwitterapiAction {
                $link = common_local_url('all', array('nickname' => $user->nickname));
                $subtitle = sprintf(_("Updates from %s and friends on %s!"), $user->nickname, $sitename);
 
-               $notice->$user->noticesWithFriends();
-               
-               $notice->limit((($page-1)*20), $count);
+               $notice->$user->noticesWithFriends(($page-1)*20, $count);
 
                $cnt = $notice->find();
                
index 1772b82e0ebf8427f07dda3ec57cfe8e77a7499a..4f46653e4383afdfbb7bead0751a9df902122ea9 100644 (file)
@@ -128,23 +128,17 @@ class User extends DB_DataObject
                
                return true;
        }
-       
-       function noticesWithFriends() {
+
+       function noticesWithFriends($offset=0, $limit=20) {
                
                $notice = new Notice();
                
-               $notice->selectAs();
-               
-               $subscription = new Subscription();
+               $notice->query('SELECT notice.* ' .
+                                          'FROM notice JOIN subscription on notice.profile_id = subscription.subscribed' .
+                                          'WHERE subscription.subscriber = ' . $this->id .
+                                          'ORDER BY created DESC, notice.id DESC ' .
+                                          'LIMIT ' . $offset . ', ' . $limit);
                
-               $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;
        }
 }