From 5fb559c8db7705464666d5565951155e49fdc717 Mon Sep 17 00:00:00 2001 From: Blue Date: Mon, 26 Feb 2024 19:49:25 +0000 Subject: [PATCH] Add `get_emote_ids_globally_filtered` --- sql_helper/mixins/emoji_hashes.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sql_helper/mixins/emoji_hashes.py b/sql_helper/mixins/emoji_hashes.py index 6cfda45..3df7191 100644 --- a/sql_helper/mixins/emoji_hashes.py +++ b/sql_helper/mixins/emoji_hashes.py @@ -20,6 +20,14 @@ async def get_all_emote_hashes_filtered(self, emote_hashes: List[str]) -> Set[st results = await self.cur.fetchall() return set(hash for hash, in results) + async def get_emote_ids_globally_filtered(self, emote_ids: List[int]) -> Set[int]: + await self.cur.execute( + "select emote_id from emote_ids where emote_id=ANY(%(emote_ids)s) and emote_hash in (select emote_hash from emote_hashes where filtered=true)", + parameters={"emote_ids": emote_ids}, + ) + results = await self.cur.fetchall() + return set(emote_id for emote_id, in results) + async def mark_emote_hash_filtered(self, emote_hash: str): await self.cur.execute( "INSERT INTO emote_hashes (emote_hash, filtered) VALUES (%(emote_hash)s, true)",