diff --git a/fix_hikka_stats.py b/fix_hikka_stats.py deleted file mode 100644 index b3069481..00000000 --- a/fix_hikka_stats.py +++ /dev/null @@ -1,53 +0,0 @@ -from app.models import Collection, CollectionComment, Anime, AnimeWatch -from sqlalchemy.orm import with_loader_criteria -from app.database import sessionmanager -from sqlalchemy import select, update, tablesample, text -from random import choice -from sqlalchemy.orm import joinedload -from app.utils import get_settings -from app import constants -import asyncio - -r = {} - - -async def fix_collection_comments(): - settings = get_settings() - - sessionmanager.init(settings.database.endpoint, echo=True) - - async with sessionmanager.session() as session: - # animes = await session.scalars( - # select(Anime) - # .join(AnimeWatch, AnimeWatch.anime_id == Anime.id) - # .filter( - # AnimeWatch.deleted == False, # noqa: E712 - # ) - # ) - # - # print(len(animes)) - # - # for anime in animes: - # print(anime.title_en, len(anime.watch)) - - for i in range(0, 1): - sample = Anime.tablesample(0.1) - random_animes = (await session.scalars(select(sample.c.id))).all() - random_anime = choice(random_animes) if random_animes else None - - if random_anime: - random_anime = str(random_anime) - - if random_anime not in r: - r[random_anime] = 0 - - r[random_anime] += 1 - print(i) - - print(r) - - await sessionmanager.close() - - -if __name__ == "__main__": - asyncio.run(fix_collection_comments())