import asyncio
import json

import aiohttp


async def main():
    pages = []
    async with aiohttp.ClientSession() as session:
        i = 1
        while True:
            async with session.get(
                f"https://gitea.parrrate.ru/api/v1/repos/PTV/radn-rs/commits?stat=true&page={i}",
                headers={"accept": "application/json"},
            ) as response:
                page = await response.json()
                if not page:
                    break
                pages.extend(page)
                print(i)
                i += 1
    with open("commits.json", "w") as file:
        json.dump(pages, file, indent=2)


asyncio.run(main())