Skip to content

add cache to endponits/publisher/build#5466

Merged
codeEmpress1 merged 1 commit intocanonical:mainfrom
codeEmpress1:add-cache-to-/endpoints/publisher/build
Nov 20, 2025
Merged

add cache to endponits/publisher/build#5466
codeEmpress1 merged 1 commit intocanonical:mainfrom
codeEmpress1:add-cache-to-/endpoints/publisher/build

Conversation

@codeEmpress1
Copy link
Copy Markdown
Contributor

@codeEmpress1 codeEmpress1 commented Nov 20, 2025

Done

  • Add cache to /endpoints/publisher/builds.py

How to QA

Testing

  • This PR has tests
  • No testing required (explain why):

Issue / Card

Fixes #

Screenshots

Copilot AI review requested due to automatic review settings November 20, 2025 08:51
@webteam-app
Copy link
Copy Markdown

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 adds Redis caching to the get_snap_repo endpoint to improve performance by caching snap information for 1 hour, reducing redundant API calls to the dashboard service.

Key changes:

  • Implements a cache-aside pattern using redis_cache with a 1-hour TTL
  • Follows the same caching approach as webapp/endpoints/publisher/listing.py
  • Caches the result of dashboard.get_snap_info() to avoid repeated API calls

Comment thread webapp/endpoints/builds.py Outdated
data = {"github_orgs": [], "github_repository": None, "github_user": None}

details = dashboard.get_snap_info(flask.session, snap_name)
snap_info_key = f"snap_info:{snap_name}"
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

The cache key construction is duplicated here and in webapp/endpoints/publisher/listing.py. Consider using the helper function get_snap_info_key() from listing.py to ensure consistency across the codebase. This could be extracted to a shared utility module or imported from listing.py.

Copilot uses AI. Check for mistakes.
Comment thread webapp/endpoints/builds.py Outdated
Comment on lines +26 to +30
snap_info_key = f"snap_info:{snap_name}"
details = redis_cache.get(snap_info_key, expected_type=dict)
if not details:
details = dashboard.get_snap_info(flask.session, snap_name)
redis_cache.set(snap_info_key, details, ttl=3600)
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

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

Missing cache invalidation strategy. When snap metadata is updated (e.g., via webapp/endpoints/publisher/settings.py or webapp/publisher/snaps/release_views.py calling snap_metadata()), this cached snap info won't be invalidated, leading to stale data.

The webapp/endpoints/publisher/listing.py file shows the pattern: after successful snap_metadata() or snap_screenshots() calls, it invalidates the cache using redis_cache.delete(snap_info_key) (lines 200 and 217). Similar invalidation should be added to other files that modify snap metadata, or this cache implementation should be revisited.

Copilot uses AI. Check for mistakes.
@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 20, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (b8b6b55) to head (debf35d).
⚠️ Report is 561 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #5466       +/-   ##
==========================================
- Coverage   66.80%       0   -66.81%     
==========================================
  Files         113       0      -113     
  Lines        3714       0     -3714     
  Branches      965       0      -965     
==========================================
- Hits         2481       0     -2481     
+ Misses       1098       0     -1098     
+ Partials      135       0      -135     

see 62 files with indirect coverage changes

🚀 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.

Copy link
Copy Markdown
Contributor

@steverydz steverydz left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@codeEmpress1 codeEmpress1 merged commit d82b3b0 into canonical:main Nov 20, 2025
12 checks passed
@codeEmpress1 codeEmpress1 deleted the add-cache-to-/endpoints/publisher/build branch November 20, 2025 11:40
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