Skip to content

refactor: reuse single discourse cache across API instances - #2831

Merged
britneywwc merged 3 commits into
canonical:mainfrom
britneywwc:discourse-cache
Aug 20, 2026
Merged

refactor: reuse single discourse cache across API instances#2831
britneywwc merged 3 commits into
canonical:mainfrom
britneywwc:discourse-cache

Conversation

@britneywwc

@britneywwc britneywwc commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Done

  • Use single Discourse cache across API instances
  • For Discourse instances without API keys, set cache as None

QA

Issue / Card

Fixes WD-37940

Screenshots

[if relevant, include a screenshot]

Copilot AI review requested due to automatic review settings July 29, 2026 03:59
@webteam-app

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Refactors the Flask app’s Discourse integrations to reduce duplicated ResponseCache instances by introducing a shared cache (and a shared TTL constant) for multiple DiscourseAPI clients.

Changes:

  • Added a CACHE_TTL constant in webapp/utils/constants.py for cache TTL configuration.
  • Created a single ubuntu_discourse_cache in webapp/app.py and reused it across several DiscourseAPI instances.
  • Set cache=None for the discuss.kubernetes.io Discourse instance.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
webapp/utils/constants.py Introduces a shared cache TTL constant for ResponseCache configuration.
webapp/app.py Reuses a single ResponseCache across multiple Discourse API instances and adjusts caching behavior for an instance without API keys.
Comments suppressed due to low confidence (1)

webapp/app.py:1172

  • PR description says Discourse instances without API keys should have cache=None, but this instance does not pass api_key/api_username and still uses the shared cache.
            cache=ubuntu_discourse_cache,

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

Comment thread webapp/app.py
Comment thread webapp/app.py Outdated
Comment thread webapp/utils/constants.py Outdated
@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.65%. Comparing base (e19382d) to head (65596b5).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2831      +/-   ##
==========================================
+ Coverage   74.63%   74.65%   +0.02%     
==========================================
  Files          19       19              
  Lines        2377     2379       +2     
==========================================
+ Hits         1774     1776       +2     
  Misses        603      603              
Flag Coverage Δ
python 74.65% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@petesfrench
petesfrench self-requested a review August 4, 2026 09:36
Comment thread webapp/app.py Outdated

@petesfrench petesfrench left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@britneywwc
britneywwc merged commit 79a8702 into canonical:main Aug 20, 2026
26 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants