#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Create monthly JSON files for 10 years (2025-2035)
"""

import os
import json

# Configuration
START_YEAR = 2025
END_YEAR = 2035
BASE_DIR = r"c:\Users\tohin\OneDrive\Desktop\бот\tg\analytics\months"

# Template for monthly file
TEMPLATE = {
    "month": "",
    "events": [],
    "stats": {
        "total_messages": 0,
        "total_callbacks": 0,
        "total_group_joins": 0,
        "total_group_leaves": 0,
        "commands": {},
        "callbacks": {},
        "users": {}
    }
}

def main():
    print("=" * 60)
    print("Creating monthly JSON files for 10 years (2025-2035)")
    print("=" * 60)
    print()

    created = 0
    skipped = 0

    # Ensure base directory exists
    os.makedirs(BASE_DIR, exist_ok=True)

    # Create files for each month
    for year in range(START_YEAR, END_YEAR + 1):
        print(f"Year: {year}")

        for month in range(1, 13):
            month_str = f"{year:04d}-{month:02d}"
            file_path = os.path.join(BASE_DIR, f"{month_str}.json")

            if os.path.exists(file_path):
                skipped += 1
                continue

            # Create file content
            data = TEMPLATE.copy()
            data["month"] = month_str
            data["stats"] = {
                "total_messages": 0,
                "total_callbacks": 0,
                "total_group_joins": 0,
                "total_group_leaves": 0,
                "commands": {},
                "callbacks": {},
                "users": {}
            }

            # Write file
            with open(file_path, 'w', encoding='utf-8') as f:
                json.dump(data, f, ensure_ascii=False, indent=2)

            print(f"  [OK] Created: {month_str}.json")
            created += 1

    print()
    print("=" * 60)
    print("Summary:")
    print("=" * 60)
    print(f"Files created: {created}")
    print(f"Files skipped (already exist): {skipped}")
    print(f"Total years: {END_YEAR - START_YEAR + 1}")
    print(f"Total months: {(END_YEAR - START_YEAR + 1) * 12}")
    print()
    print("Structure:")
    print("analytics/")
    print("├── queue.json")
    print("├── lock.txt")
    print("└── months/")
    print("    ├── 2025-01.json")
    print("    ├── 2025-02.json")
    print("    ├── ...")
    print("    ├── 2035-11.json")
    print("    └── 2035-12.json")
    print()
    print("[SUCCESS] Done!")

if __name__ == "__main__":
    main()
