randomize tag list

This commit is contained in:
bakatrouble 2023-07-24 00:50:51 +03:00
parent cc46539ea9
commit 304b61f87d

View File

@ -1,6 +1,7 @@
import asyncio import asyncio
import logging import logging
import os import os
import random
from io import BytesIO from io import BytesIO
from pathlib import Path from pathlib import Path
from tempfile import TemporaryFile, TemporaryDirectory from tempfile import TemporaryFile, TemporaryDirectory
@ -109,7 +110,7 @@ async def check_updates():
async with redis.lock('e621:update'): async with redis.lock('e621:update'):
logging.warning('Lock acquired...') logging.warning('Lock acquired...')
tag_list = [t.decode() for t in await redis.smembers('e621:subs')] tag_list = [t.decode() for t in await redis.smembers('e621:subs')]
tag_list.sort() random.shuffle(tag_list)
for tl_idx in range(0, len(tag_list), 40): for tl_idx in range(0, len(tag_list), 40):
tags = ' '.join(f'~{tag}' for tag in tag_list[tl_idx: tl_idx + 40]) tags = ' '.join(f'~{tag}' for tag in tag_list[tl_idx: tl_idx + 40])
logging.warning(tags) logging.warning(tags)