-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into coda/stitching
- Loading branch information
Showing
11 changed files
with
509 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
xmtp_mls/migrations/2024-12-20-143210_create_conversation_list_view/down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP VIEW IF EXISTS conversation_list; |
47 changes: 47 additions & 0 deletions
47
xmtp_mls/migrations/2024-12-20-143210_create_conversation_list_view/up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
CREATE VIEW conversation_list AS | ||
WITH ranked_messages AS ( | ||
SELECT | ||
gm.group_id, | ||
gm.id AS message_id, | ||
gm.decrypted_message_bytes, | ||
gm.sent_at_ns, | ||
gm.kind AS message_kind, | ||
gm.sender_installation_id, | ||
gm.sender_inbox_id, | ||
gm.delivery_status, | ||
gm.content_type, | ||
gm.version_major, | ||
gm.version_minor, | ||
gm.authority_id, | ||
ROW_NUMBER() OVER (PARTITION BY gm.group_id ORDER BY gm.sent_at_ns DESC) AS row_num | ||
FROM | ||
group_messages gm | ||
WHERE | ||
gm.kind = 1 | ||
) | ||
SELECT | ||
g.id AS id, | ||
g.created_at_ns, | ||
g.membership_state, | ||
g.installations_last_checked, | ||
g.added_by_inbox_id, | ||
g.welcome_id, | ||
g.dm_inbox_id, | ||
g.rotated_at_ns, | ||
g.conversation_type, | ||
rm.message_id, | ||
rm.decrypted_message_bytes, | ||
rm.sent_at_ns, | ||
rm.message_kind, | ||
rm.sender_installation_id, | ||
rm.sender_inbox_id, | ||
rm.delivery_status, | ||
rm.content_type, | ||
rm.version_major, | ||
rm.version_minor, | ||
rm.authority_id | ||
FROM | ||
groups g | ||
LEFT JOIN ranked_messages rm | ||
ON g.id = rm.group_id AND rm.row_num = 1 | ||
ORDER BY COALESCE(rm.sent_at_ns, g.created_at_ns) DESC; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.