Skip to content

Fix caching issue in processes content block#15988

Merged
alecslupu merged 4 commits intodevelopfrom
fix/cache-process-content-block
Feb 4, 2026
Merged

Fix caching issue in processes content block#15988
alecslupu merged 4 commits intodevelopfrom
fix/cache-process-content-block

Conversation

@andreslucena
Copy link
Copy Markdown
Member

@andreslucena andreslucena commented Feb 4, 2026

🎩 What? Why?

As explained on #15963, there's a caching issue in the "Highlighted Processes" content block of the homepage.

📌 Related Issues

Testing

  1. Enable caching locally with bin/rails dev:cache
  2. Restart or start the rails server
  3. Go to the homepage
  4. Log in as admin
  5. Edit the process that's visible in the homepage, add a new step, activate
  6. Go back to the homepage
  7. (Without the change) See that the step is the same as the one from step 3
  8. (With the change) See that the step changes to the one from the step 5

📷 Screenshots

image

♥️ Thank you!

Summary by CodeRabbit

  • Bug Fixes

    • Improved cache invalidation for participatory processes to ensure content changes in process steps are immediately reflected, preventing display of outdated information.
  • Tests

    • Added comprehensive tests to verify proper cache behavior and parent process updates when steps are modified.

Copilot AI review requested due to automatic review settings February 4, 2026 06:35
@andreslucena andreslucena added the type: fix PRs that implement a fix for a bug label Feb 4, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 4, 2026

📝 Walkthrough

Walkthrough

These changes implement cache invalidation for featured processes content blocks. A touch: true option is added to the ParticipatoryProcessStep association with its parent ParticipatoryProcess, ensuring the parent's updated_at timestamp updates when steps are modified. Tests verify cache invalidation occurs when process steps change.

Changes

Cohort / File(s) Summary
Model Association Update
decidim-participatory_processes/app/models/decidim/participatory_process_step.rb
Added touch: true to the belongs_to :participatory_process association, causing parent process records to be touched (updated_at changed) when a step is modified.
Model Tests
decidim-participatory_processes/spec/models/decidim/participatory_process_step_spec.rb
Added two new tests verifying that updating a step touches the parent process and invalidates its cache_key_with_version.
Cell Cache Tests
decidim-participatory_processes/spec/cells/decidim/participatory_processes/content_blocks/highlighted_processes_cell_spec.rb
Added comprehensive test suite for HighlightedProcessesCell#cache_hash stability across reloads, process updates, locale changes, and step title modifications.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A process step now nudges its parent awake,
When changes are made, the cache must break!
The featured blocks now refresh with delight,
No stale phases showing—the phases are right! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix caching issue in processes content block' directly aligns with the main change—addressing cache invalidation in the highlighted processes content block by adding touch behavior to parent updates.
Linked Issues check ✅ Passed The PR successfully addresses issue #15963 by implementing cache invalidation when process steps are updated, verified by comprehensive test coverage for cache_hash behavior.
Out of Scope Changes check ✅ Passed All changes are focused on fixing the caching issue: adding touch behavior to step-process association, and adding tests to verify cache invalidation on updates—nothing out of scope.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/cache-process-content-block

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

github-actions[bot]
github-actions bot previously approved these changes Feb 4, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a caching issue in the highlighted processes content block on the homepage. When a participatory process's active step changes, the cache was not being invalidated, causing the homepage to display stale step information.

Changes:

  • Updated the cache_hash method in HighlightedParticipatorySpacesCell to include the active step's cache key in the cache calculation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

github-actions[bot]
github-actions bot previously approved these changes Feb 4, 2026
@alecslupu alecslupu self-assigned this Feb 4, 2026
@alecslupu alecslupu added release: v0.30 Issues or PRs that need to be tackled for v0.30 release: v0.31 Issues or PRs that need to be tackled for v0.31 labels Feb 4, 2026
Copy link
Copy Markdown
Contributor

@alecslupu alecslupu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would go for another approach on this PR. The way is implemented now, is adding an extra query for each one of the highlighted processes in the page, just to build cache.

Why not a simple touch the Process after the Step is updated?

@andreslucena
Copy link
Copy Markdown
Member Author

Why not a simple touch the Process after the Step is updated?

Oh... the only reason why I didn't do it like that is that I didn't have the idea 🤣

I applied it. I also left the specs and added a model spec to leave it documented just in case

Copy link
Copy Markdown
Contributor

@alecslupu alecslupu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better - Merging with failing pipeline on qlty.

@alecslupu alecslupu merged commit 7d14b69 into develop Feb 4, 2026
49 of 50 checks passed
@alecslupu alecslupu deleted the fix/cache-process-content-block branch February 4, 2026 22:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: core module: participatory processes release: v0.30 Issues or PRs that need to be tackled for v0.30 release: v0.31 Issues or PRs that need to be tackled for v0.31 type: fix PRs that implement a fix for a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The process phases are not updated in the process content block on the home page when I change the phase or change the text

3 participants