From 27a1244c2a43c7d028d56fd3fae71238b23abd0d Mon Sep 17 00:00:00 2001 From: iequidoo Date: Thu, 28 Nov 2024 17:56:57 -0300 Subject: [PATCH] 2squash: Optimize another SQL statement --- src/chat.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/chat.rs b/src/chat.rs index 7915520c84..a886a7b880 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -3352,11 +3352,13 @@ pub async fn marknoticed_chat(context: &Context, chat_id: ChatId) -> Result<()> .filter(|&(_, state)| state == MessageState::InFresh) .map(|(id, _)| id); + // NB: Enumerate `hidden` values to employ `msgs_index7`. let nr_msgs_noticed = conn.execute( "UPDATE msgs SET state=? WHERE state=? - AND chat_id=?", + AND (hidden=0 OR hidden=1) + AND chat_id=?", (MessageState::InNoticed, MessageState::InFresh, chat_id), )?; Ok((nr_msgs_noticed, id_to_markseen))