Drop out channel hash helper

This commit is contained in:
Jack Kingsman
2026-03-12 20:33:52 -07:00
parent 5a580b9c01
commit a7ff041a48
8 changed files with 30 additions and 48 deletions
+13
View File
@@ -857,6 +857,19 @@ class MessageRepository:
"top_senders_24h": top_senders,
}
@staticmethod
async def count_channels_with_incoming_messages() -> int:
"""Count distinct channel conversations with at least one incoming message."""
cursor = await db.conn.execute(
"""
SELECT COUNT(DISTINCT conversation_key) AS cnt
FROM messages
WHERE type = 'CHAN' AND outgoing = 0
"""
)
row = await cursor.fetchone()
return int(row["cnt"]) if row and row["cnt"] is not None else 0
@staticmethod
async def get_most_active_rooms(sender_key: str, limit: int = 5) -> list[tuple[str, str, int]]:
"""Get channels where a contact has sent the most messages.