From 66474586af58c4e505117f0fed7382831ec008b1 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 17 Dec 2010 14:51:37 -0800 Subject: [PATCH] Update sorting for group inbox timelines; adds group_inbox_group_id_created_notice_id_idx index to group_inbox table --- classes/User_group.php | 11 +++-------- db/096to097.sql | 3 +++ db/statusnet.sql | 5 ++++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/classes/User_group.php b/classes/User_group.php index 60217e960e..cffc786458 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 4171e95897..c3f1fb4253 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 dfc46f79e2..5898abf463 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; -- 2.39.5