summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-12-17 14:51:37 -0800
committerBrion Vibber <brion@pobox.com>2010-12-17 14:51:37 -0800
commit66474586af58c4e505117f0fed7382831ec008b1 (patch)
tree6074fa183c7f68a251feb8749192a68937a4e823
parent3ddfa4de931f4eb3083ac877898b5ee8b03a82f1 (diff)
Update sorting for group inbox timelines; adds group_inbox_group_id_created_notice_id_idx index to group_inbox table
-rw-r--r--classes/User_group.php11
-rw-r--r--db/096to097.sql3
-rw-r--r--db/statusnet.sql5
3 files changed, 10 insertions, 9 deletions
diff --git a/classes/User_group.php b/classes/User_group.php
index 60217e960..cffc78645 100644
--- a/classes/User_group.php
+++ b/classes/User_group.php
@@ -100,15 +100,10 @@ class User_group extends Memcached_DataObject
$inbox->selectAdd();
$inbox->selectAdd('notice_id');
- if ($since_id != 0) {
- $inbox->whereAdd('notice_id > ' . $since_id);
- }
-
- if ($max_id != 0) {
- $inbox->whereAdd('notice_id <= ' . $max_id);
- }
+ Notice::addWhereSinceId($inbox, $since_id, 'notice_id');
+ Notice::addWhereMaxId($inbox, $max_id, 'notice_id');
- $inbox->orderBy('notice_id DESC');
+ $inbox->orderBy('created DESC, notice_id DESC');
if (!is_null($offset)) {
$inbox->limit($offset, $limit);
diff --git a/db/096to097.sql b/db/096to097.sql
index 4171e9589..c3f1fb425 100644
--- a/db/096to097.sql
+++ b/db/096to097.sql
@@ -8,3 +8,6 @@ alter table notice_tag add index notice_tag_tag_created_notice_id_idx (tag, crea
-- Needed for sorting reply/mentions timelines
alter table reply add index reply_profile_id_modified_notice_id_idx (profile_id, modified, notice_id);
+
+-- Needed for sorting group messages by timestamp
+alter table group_inbox add index group_inbox_group_id_created_notice_id_idx (group_id, created, notice_id);
diff --git a/db/statusnet.sql b/db/statusnet.sql
index dfc46f79e..5898abf46 100644
--- a/db/statusnet.sql
+++ b/db/statusnet.sql
@@ -480,7 +480,10 @@ create table group_inbox (
constraint primary key (group_id, notice_id),
index group_inbox_created_idx (created),
- index group_inbox_notice_id_idx (notice_id)
+ index group_inbox_notice_id_idx (notice_id),
+
+ -- Needed for sorting group messages by timestamp
+ index group_inbox_group_id_created_notice_id_idx (group_id, created, notice_id)
) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;