feat: add stats command#2
Merged
Merged
Conversation
Implement odoo-db CLI for local Odoo database management. Commands: list, modules, crons, jobs, users, locks - list: all local Odoo DBs with version, neutralized status; --verbose adds module/user count - modules: installed modules with version - crons: active scheduled actions - jobs: queue job counts by state - users: active users with online/away/offline status (via bus_presence or mail_presence) - locks: active DB locks with blocked/blocking PIDs and queries Features: - psycopg3 Unix socket connection (peer auth, no credentials) - Output formats: text (rich table with borders), json, prometheus - Logging: --log-level/--log-file, auto-created logs dir - Friendly error messages for DB connection failures - GitHub Actions: CI tests (pytest), pre-commit, semantic release to PyPI - Smoke tests for CLI help commands
…eakdown New command: odoo-db stats <db> [--years N] [--top N] - Top N tables by size with: total records, table size, index sizes, attachment sizes (dedup by checksum), and per-year record counts - Detects Odoo tables via pg_attribute (create_date column) - Maps table names to Odoo model names via ir_model - Uses sql.Identifier + make_interval for safe dynamic SQL - Footer row showing totals across top N tables - Column legend explaining each metric - Supports text (rich table), json, prometheus output formats - Tested on Odoo 16, 17, 18, 19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
odoo-db stats <db>— per-table record counts, sizes, and year breakdown--years N(default 3),--top N(default 20 tables by size)ir_modelsql.Identifier+make_intervalfor safe dynamic SQLtext(rich table),json,prometheusoutput formatsTest plan
odoo-db stats <db>— shows top 20 tables with all metricsodoo-db stats <db> --years 5 --top 10— custom years/topodoo-db --output-format json stats <db>— JSON outputodoo-db --output-format prometheus stats <db>— Prometheus output