Skip to content

Feat/cs/handle recoverable with filter#427

Merged
ReagentX merged 13 commits intodevelopfrom
feat/cs/handle-recoverable-with-filter
Jan 11, 2025
Merged

Feat/cs/handle recoverable with filter#427
ReagentX merged 13 commits intodevelopfrom
feat/cs/handle-recoverable-with-filter

Conversation

@ReagentX
Copy link
Owner

@ReagentX ReagentX commented Jan 9, 2025

@ReagentX ReagentX added bug Something isn't working crate: database Related to the database crate crate: cli Related to the CLI crate table Related to table data labels Jan 9, 2025
@ReagentX ReagentX self-assigned this Jan 9, 2025
@ReagentX
Copy link
Owner Author

ReagentX commented Jan 9, 2025

The major change here is to the SQL we use to generate the message stream:

SELECT
    m.*,
    c.chat_id,
    (SELECT COUNT(*) FROM message_attachment_join a WHERE m.ROWID = a.message_id) as num_attachments,
    d.chat_id as deleted_from,
    (SELECT COUNT(*) FROM message m2 WHERE m2.thread_originator_guid = m.guid) as num_replies
FROM
    message as m
LEFT JOIN chat_message_join as c ON m.ROWID = c.message_id
LEFT JOIN chat_recoverable_message_join as d ON m.ROWID = d.message_id
WHERE
    (c.chat_id IN (1, 2, 3) OR d.chat_id IN (1, 2, 3))
ORDER BY
    m.date;

Previously, we used

SELECT
    m.*,
    c.chat_id,
    (SELECT COUNT(*) FROM MESSAGE_ATTACHMENT_JOIN a WHERE m.ROWID = a.message_id) as num_attachments,
    (SELECT b.chat_id FROM RECENTLY_DELETED b WHERE m.ROWID = b.message_id) as deleted_from,
    (SELECT COUNT(*) FROM MESSAGE m2 WHERE m2.thread_originator_guid = m.guid) as num_replies
FROM
    message as m
LEFT JOIN CHAT_MESSAGE_JOIN as c ON m.ROWID = c.message_id
WHERE
    c.chat_id IN (1, 2, 3)
ORDER BY
    m.date;

The salient difference is that we query for deleted_from in a LEFT JOIN, allowing us to filter chat_id in both places: (c.chat_id IN (1, 2, 3) OR d.chat_id IN (1, 2, 3)).

@ReagentX ReagentX merged commit 854e717 into develop Jan 11, 2025
1 check passed
@ReagentX ReagentX deleted the feat/cs/handle-recoverable-with-filter branch January 11, 2025 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working crate: cli Related to the CLI crate crate: database Related to the database crate table Related to table data

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

Recoverable deleted messages are omitted when --conversation-filter is set ImageMagick and FFmpeg not discovered on Arch Linux

1 participant

Comments