feat(dashboard): real stats, system info panel, indexes and caching - #26
Merged
Merged
Conversation
- Cache module list on app.state.modules at startup instead of calling discover_modules() on every request (expensive entry-point rescan) - Parallelize health checks with asyncio.gather instead of sequential loop - Extract health status color map in Home.tsx, type accent as union - Use typed literal unions for HealthCheck.status and SystemModule.status - Deduplicate test setup with shared pytest fixture for stats call
- Add index on User.last_login_at (used by active users 7d query) - Add index on Product.is_active (used by product count query) - Add Alembic migration for both indexes - Cache fetch_dashboard_stats result for 30 seconds to avoid repeated DB round-trips on rapid page loads - Expose invalidate_stats_cache() for test isolation
Move User.last_login_at index test to users/tests/test_models.py and Product.is_active index test to products/tests/test_products.py so each module owns its own schema guarantees.
- Add asyncio.Lock to prevent concurrent coroutines from bypassing the TTL check and duplicating DB queries - Return .copy() of cached dict to prevent caller mutation - Remove unused `welcome` prop from Home.tsx Props interface - Remove unnecessary JSX section comments - Align _has_index_on helper pattern in products tests
- ruff format on stats.py and migration file - biome format on generated i18n files (double→single quotes) - Trim test_models.py to 298 lines (was 307, cap is 300) - Remove dead welcome prop and section comments from Home.tsx
- biome format Home.tsx (collapse multi-line imports) - biome check i18n generated files (double→single quotes, organize imports) - ruff fix migration (remove unused sqlalchemy import, sort imports) - ruff format test_models.py
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
Replaces the placeholder dashboard with a data-rich overview showing real user/product counts and system information.
stats.py): queriesusers_userandproducts_producttables, reads module list fromapp.state.modules, runs health checks concurrently viaasyncio.gatherasyncio.Lockto prevent concurrent coroutine stampedesix_users_user_last_login_atandix_products_product_is_activewith Alembic migration and guard tests in each owning modulehandlers.pydeleted), event bus subscriptions from dashboard moduleChanges
modules/dashboard/dashboard/stats.py(new),endpoints/api.py,endpoints/views.pymodules/dashboard/dashboard/pages/Home.tsx(rewritten)module.py,pyproject.toml(added Users dependency)locales/en.json,locales/es.jsonmodules/users/users/models.py,modules/products/products/models.py, migrationapp_builder.py(store modules onapp.state)test_dashboard.py(rewritten), index guards intest_models.pyandtest_products.pyhandlers.py(deleted)Test plan