Optimized review_pull_requests.py to use git for-each-ref with the ahead-behind atom to prefetch all branch metadata in a single call. This reduces execution time from ~1.6s to ~0.4s (~75% reduction) on repositories with many branches by eliminating N+1 git log calls.
This commit introduces several performance optimizations to the Flask web dashboard:
1. Consolidated file metadata checks in `MarkdownCache` using `os.stat()`. This reduces the number of system calls per request by retrieving both file existence and modification time in a single operation.
2. Extracted the large HTML template into a module-level constant `DASHBOARD_TEMPLATE`. This eliminates redundant memory allocations and string concatenations within the request lifecycle.
3. Pre-defined markdown file paths as constants to avoid repeated `os.path.join()` calls.
4. Simplified `render_template_string` calls by hardcoding static values (like the footer year).
These changes reduce CPU overhead and latency for both the main dashboard and the health check endpoint. Verified via integration tests and Playwright screenshots.
This commit implements a caching mechanism for the web dashboard's Markdown content.
Previously, README.md and VERIFICATION.md were read and rendered on every request.
Now, they are cached and only re-rendered if the file modification time (mtime) changes.
This significantly reduces CPU and I/O overhead for dashboard requests.
Key changes:
- Added MarkdownCache class to scripts/web_dashboard.py
- Moved file path definitions to module level
- Updated health_check route to use cached HTML
- Verified logic with standalone test script (mocked)
- Updated .jules/bolt.md journal with this learning
# Vercel Web Analytics Implementation
## Summary
Successfully implemented Vercel Web Analytics for the MQL5 Trading Automation dashboard project. The implementation follows Vercel's recommended HTML/plain JavaScript approach, which is ideal for this Flask-based application.
## Changes Made
### Modified Files:
1. **dashboard/index.html**
- Added Vercel Web Analytics script tags before the closing `</body>` tag
- Implemented the standard HTML analytics tracking code that initializes the `window.va` function
- Added deferred loading of the Vercel insights script from `/_vercel/insights/script.js`
2. **scripts/web_dashboard.py**
- Updated the Flask application's HTML template to include Vercel Web Analytics
- Added the same analytics script tags to the dynamically generated HTML
- Ensures analytics tracking works on both the static and Flask-rendered pages
### Created Files:
3. **vercel.json**
- Created Vercel deployment configuration file
- Configured builds for both the Python Flask app and static dashboard files
- Set up routing to properly serve the Flask app and static assets
- Added production environment variables for Flask
## Implementation Details
The implementation uses Vercel's HTML/JavaScript approach for web analytics, which:
- Requires no package installation (no @vercel/analytics npm package needed)
- Works seamlessly with Flask and static HTML pages
- Automatically tracks page views and visitor metrics
- Uses deferred script loading for optimal performance
- Will be activated once the project is deployed to Vercel with Web Analytics enabled
## Next Steps for Deployment
To complete the Vercel Web Analytics setup:
1. **Enable Web Analytics in Vercel Dashboard:**
- Go to your Vercel project dashboard
- Click the "Analytics" tab
- Click "Enable" to activate Web Analytics
- This will make the `/_vercel/insights/*` routes available
2. **Deploy to Vercel:**
- Run `vercel deploy` or push to your connected Git repository
- The analytics will automatically start tracking after deployment
3. **Verify Installation:**
- After deployment, visit your site
- Open browser DevTools > Network tab
- Look for a request to `/_vercel/insights/view` to confirm tracking is active
## Technical Notes
- No changes to requirements.txt were needed (Python-only dependencies)
- No package manager operations required (npm/yarn/pnpm)
- The implementation is framework-agnostic and works with plain HTML/JavaScript
- Analytics tracking is non-blocking and won't affect page load performance
- The solution supports both the static HTML dashboard and Flask-rendered pages
Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
- Implemented a Flask-based web dashboard in `scripts/web_dashboard.py` to serve project status and documentation.
- Integrated the web dashboard into `config/startup_config.json` as a managed component.
- Updated `requirements.txt` with `flask` and `markdown` dependencies.
- Added `/health` endpoint for cloud platform health checks.
- Verified system integrity with existing validation and testing scripts.
Refactored `scripts/test_automation.py` to run independent integration tests in parallel using `concurrent.futures.ProcessPoolExecutor`.
* 💡 **What:** Used `ProcessPoolExecutor` to run tests concurrently.
* 🎯 **Why:** To improve test suite performance.
* 📊 **Measured Improvement:** ~30% faster (3.3s -> 2.25s).
* **Details:** Used processes instead of threads to ensure `contextlib.redirect_stdout` works correctly for each test without interference.
- Fix cron entry to use absolute paths instead of variables
- Add parents=True to mkdir for better error handling
- Change PowerShell scheduled task to use Limited privileges for security
- All tests still passing
Co-authored-by: Mouy-leng <199350297+Mouy-leng@users.noreply.github.com>
- AUTOMATION_FEATURES.md with comprehensive feature overview
- Integration test suite for verifying all scripts
- Logs directory README for documentation
- All tests passing successfully
Co-authored-by: Mouy-leng <199350297+Mouy-leng@users.noreply.github.com>
- Python orchestrator with JSON config, logging, and monitoring
- Windows batch script for simple automation
- PowerShell script with scheduled task creation
- Linux/WSL shell script with systemd/cron support
- Detailed documentation and quick start guides
- Example custom script template
- Configuration file with MT5 paths
- Updated .gitignore for logs and temp files
Co-authored-by: Mouy-leng <199350297+Mouy-leng@users.noreply.github.com>