feat: add group filter to product and plan listing endpoints#735
Open
carlosmfreitas2409 wants to merge 1 commit intouseautumn:devfrom
Open
feat: add group filter to product and plan listing endpoints#735carlosmfreitas2409 wants to merge 1 commit intouseautumn:devfrom
carlosmfreitas2409 wants to merge 1 commit intouseautumn:devfrom
Conversation
|
@carlosmfreitas2409 is attempting to deploy a commit to the Autumn Team on Vercel. A member of the Team first needs to authorize it. |
Comment on lines
237
to
+240
| key: buildProductsCacheKey({ | ||
| orgId, | ||
| env, | ||
| queryParams: { archived }, | ||
| queryParams: { archived, group }, |
Contributor
There was a problem hiding this comment.
Cache invalidation in invalidateProductsCache() doesn't account for group-filtered cache entries. When products are modified, cached queries with different group parameter values won't be invalidated, leading to stale data.
The invalidateProductsCache() function in productCacheUtils.ts only invalidates cache keys for archived parameter variants, but now that group is part of the cache key hash, queries like ?group=premium will remain cached even after product updates.
Prompt To Fix With AI
This is a comment left during a code review.
Path: server/src/internal/products/ProductService.ts
Line: 237:240
Comment:
Cache invalidation in `invalidateProductsCache()` doesn't account for group-filtered cache entries. When products are modified, cached queries with different `group` parameter values won't be invalidated, leading to stale data.
The `invalidateProductsCache()` function in `productCacheUtils.ts` only invalidates cache keys for `archived` parameter variants, but now that `group` is part of the cache key hash, queries like `?group=premium` will remain cached even after product updates.
How can I resolve this? If you propose a fix, please make it concise.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add group filter to product and plan listing endpoints — Both the public GET /plans and internal GET /products endpoints now accept an optional group query parameter, which filters products by their group field.
PR in SDK: useautumn/typescript#71
Type of Change
Checklist
Greptile Overview
Greptile Summary
Added optional
groupquery parameter to product and plan listing endpoints, enabling filtering of products by their group field.API changes
GET /plansendpoint now accepts optionalgroupquery parameterGET /products/productsendpoint now accepts optionalgroupquery parameterImprovements
groupparameter in hash for cache differentiationBug fixes
Confidence Score: 3/5
productCacheUtils.tsonly handlesarchivedparameter variants and doesn't account for group-filtered cache entries. This means when products are modified, stale cached data may persist for queries with specific group filters. The core functionality works correctly, but the caching issue could lead to data inconsistency until cache TTL expires (1 day).server/src/internal/products/ProductService.ts- the cache invalidation logic needs to be updated to handle group-filtered cache entriesImportant Files Changed
groupquery parameter to ListPlansQuerySchema for filtering plans by groupgroupfrom query parameters and passed it to ProductService.listFull for filteringgroupquery parameter extraction and passed it to ProductService.listFull for internal products endpointgroupparameter to listFull and _listFullQuery methods with database filtering and cache key integration, but cache invalidation doesn't account for group-filtered cache entriesSequence Diagram
sequenceDiagram participant Client participant handleListPlans participant ProductService participant Cache participant Database Client->>handleListPlans: GET /plans?group=premium handleListPlans->>ProductService: listFull({orgId, env, group: "premium"}) ProductService->>ProductService: Check if canCache alt Can use cache ProductService->>Cache: buildProductsCacheKey({orgId, env, queryParams: {group}}) Cache-->>ProductService: Cache key with group hash ProductService->>Cache: queryWithCache(key, fn) alt Cache hit Cache-->>ProductService: Cached products else Cache miss ProductService->>Database: _listFullQuery with group filter Database-->>ProductService: Filtered products ProductService->>Cache: Store with group-specific key end else Cannot use cache ProductService->>Database: _listFullQuery directly Database-->>ProductService: Filtered products end ProductService-->>handleListPlans: Products filtered by group handleListPlans-->>Client: JSON response with filtered plans(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!