check that monitored tags are in added tags

This commit is contained in:
bakatrouble 2024-02-29 12:37:37 +03:00
parent 501c9ca1ab
commit 49faf9f746

View File

@ -140,6 +140,7 @@ async def check_updates():
logging.warning('Lock acquired...') logging.warning('Lock acquired...')
matched_posts = [] matched_posts = []
tag_list = set(tuple(t.decode().split()) for t in await redis.smembers('e621:subs')) tag_list = set(tuple(t.decode().split()) for t in await redis.smembers('e621:subs'))
tag_list_flat = set(sum(tag_list, ()))
last_post_version = int((await redis.get('e621:last_version') or b'0').decode()) last_post_version = int((await redis.get('e621:last_version') or b'0').decode())
post_versions: List[E621PostVersion] = [] post_versions: List[E621PostVersion] = []
logging.warning(f'Getting post versions from id {last_post_version}') logging.warning(f'Getting post versions from id {last_post_version}')
@ -152,6 +153,8 @@ async def check_updates():
for post_version in post_versions[::-1]: for post_version in post_versions[::-1]:
if post_version.id > last_post_version: if post_version.id > last_post_version:
last_post_version = post_version.id last_post_version = post_version.id
if not bool(tag_list_flat & set(post_version.added_tags)):
continue
post_tags = set(post_version.tags.split()) post_tags = set(post_version.tags.split())
for tag_group in tag_list: for tag_group in tag_list:
if set(tag_group) <= post_tags: if set(tag_group) <= post_tags: