$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);
-- 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);
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;