eschutho opened a new pull request, #45873:
URL: https://github.com/apache/superset/pull/45873

   ### SUMMARY
   Adds an opt-in setting, `CACHE_WARMUP_ON_LOGIN` (default `False`), that gets 
a user's favorited dashboards ready as soon as they log in.
   
   After a successful login, a background Celery task runs as that user and 
goes through the charts on their most recently favorited dashboards. A chart is 
only computed if its cached result is missing or expired. Charts that are 
already cached are left alone, so no queries are repeated needlessly. Login 
itself is never delayed: the task is queued, and any failure while queuing is 
logged and ignored.
   
   Design notes:
   - The task runs as the logging-in user, not the shared warm-up user, because 
cache keys depend on the requesting user (row-level security, impersonation). 
Warming under another user would not help them. Dashboard and chart access is 
checked for that user.
   - It reuses `ChartWarmUpCacheCommand` instead of duplicating query logic. A 
new `only_if_stale` option makes it check the data cache first and fill misses 
without bypassing the cache. The existing "always force refresh" behavior is 
unchanged when the option is not used.
   - Bounds: `CACHE_WARMUP_ON_LOGIN_MAX_DASHBOARDS` (default 5, newest 
favorites first) and a per-user `CACHE_WARMUP_ON_LOGIN_COOLDOWN` (default 1 
hour, `0` disables) limit the work per login.
   - Needs a Celery worker and a real `DATA_CACHE_CONFIG` backend.
   - Dashboard default filters are not applied, so a dashboard load that uses 
different default filters can still miss the cache for those charts.
   
   ### TESTING INSTRUCTIONS
   Unit tests: `pytest tests/unit_tests/tasks/test_cache.py 
tests/unit_tests/commands/chart/warm_up_cache_test.py 
tests/unit_tests/security/audit_log_test.py`
   
   Manual: configure Redis for `DATA_CACHE_CONFIG`/`CACHE_CONFIG` and run a 
Celery worker. Set `CACHE_WARMUP_ON_LOGIN = True`, favorite a dashboard, clear 
its cache, log out and in, and confirm the worker computes the charts. Log out 
and in again after clearing the cooldown key: nothing is recomputed while the 
cache is warm.
   
   ### ADDITIONAL INFORMATION
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration
   - [x] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to