EDM115 / unzip-bot

Telegram bot deployable to heroku that can extract every archive !
https://t.me/unzip_edm115bot
MIT License
105 stars 131 forks source link

Database rework #356

Open EDM115 opened 2 weeks ago

EDM115 commented 2 weeks ago

Redo the database, have less collections (hopefully reduces requests), allow for a local deployment and a local .json entry

Current state of the database :

erDiagram
    USERS_DB {
        int user_id
    }
    BANNED_USERS_DB {
        int banned_user_id
    }
    ULMODE_DB {
        int _id PK
        string mode
    }
    UPLOADED_COUNT_DB {
        int _id PK
        int uploaded_files
    }
    THUMB_DB {
        int _id PK
        string file_id
        string temp
        string url
    }
    BOT_DATA {
        bool boot
        datetime time
        bool old_boot
    }
    ONGOING_TASKS {
        int user_id
        datetime start_time
        string type
    }
    CANCEL_TASKS {
        int user_id
    }
    MERGE_TASKS {
        int user_id
        int message_id
    }
    MAINTENANCE_MODE {
        bool maintenance
        bool val
    }
    VIP_USERS {
        int _id PK
        string subscription
        datetime ends
        int used
        float billed
        bool early
        bool donator
        datetime started
        int successful
        int gap
        bool gifted
        bool referral
        bool lifetime
    }
    REFERRALS {
        int _id PK
        string type
        string referral_code
        int referees[]
    }

    USERS_DB ||--o{ BANNED_USERS_DB : "1 : 1"
    USERS_DB ||--o{ ULMODE_DB : "1 : 1"
    USERS_DB ||--o{ UPLOADED_COUNT_DB : "1 : 1"
    USERS_DB ||--o{ THUMB_DB : "1 : 1"
    USERS_DB ||--o{ ONGOING_TASKS : "1 : n"
    USERS_DB ||--o{ CANCEL_TASKS : "1 : n"
    USERS_DB ||--o{ MERGE_TASKS : "1 : n"
    USERS_DB ||--o{ VIP_USERS : "1 : 1"
    USERS_DB ||--o{ REFERRALS : "1 : 1"
    MAINTENANCE_MODE ||--o{ BOT_DATA : "1 : 1"
EDM115 commented 3 days ago

After more thoughts into this, here's the quick rundown of what's needed :

The new DB scheme still have to be made

Motor 3.6.0 Released
We are pleased to announce the 3.6.0 release of Motor - MongoDB’s Asynchronous Python Driver. This release has the following changes: Add support for MongoDB 8.0 and PyMongo 4.9. The length parameter in MotorCursor.to_list is now optional. Note This is the last planned minor version of Motor. We are sunsetting Motor in favor of native asyncio support in PyMongo 4.9+. We will continue to provide security releases and bug fixes for Motor, but it will not gain new features.
MongoDB PyMongo Documentation
Migrate from Motor to PyMongo Async
Switch from PyMongo to PyMongo Async
What's New
Database normalization - Wikipedia
GitHub - omnilib/aiosqlite: asyncio bridge to the standard sqlite3 module
asyncio bridge to the standard sqlite3 module. Contribute to omnilib/aiosqlite development by creating an account on GitHub.