feat: Add folder organization for feature flags#327
feat: Add folder organization for feature flags#327dagangtj wants to merge 2 commits intodatabuddy-analytics:mainfrom
Conversation
- Add folder text field to flags table schema - Add index on folder and websiteId for performance - Support folder parameter in flags.list endpoint - Support folder field in flags.create and flags.update - Backward compatible: folder is optional
|
@dagangtj is attempting to deploy a commit to the Databuddy OSS Team on Vercel. A member of the Team first needs to authorize it. |
|
|
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Greptile SummaryAdded folder organization capability for feature flags by introducing a nullable Key Changes:
Issues Found:
Confidence Score: 2/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[flags.list API call] --> B{folder param provided?}
B -->|No| C[Build cache key with 'all']
B -->|Yes| D[Build cache key with folder value]
C --> E[Check cache]
D --> E
E -->|Cache hit| F[Return cached results]
E -->|Cache miss| G[Build DB query]
G --> H{folder !== undefined?}
H -->|No| I[Query without folder filter]
H -->|Yes| J[Query with eq folder, folder]
I --> K[Return all flags]
J --> L[Return filtered flags]
K --> M[Cache results]
L --> M
M --> N[Return to client]
style B fill:#f9f,stroke:#333
style H fill:#f9f,stroke:#333
style E fill:#bbf,stroke:#333
Last reviewed commit: d911624 |
packages/rpc/src/routers/flags.ts
Outdated
| .handler(({ context, input }) => { | ||
| const scope = getScope(input.websiteId, input.organizationId); | ||
| const cacheKey = `list:${scope}:${input.status || "all"}`; | ||
| const cacheKey = `list:${scope}:${input.status || "all"}:${input.folder || "all"}`; |
There was a problem hiding this comment.
cache key doesn't distinguish between undefined (no filter), null (filter for null folders), and empty string (filter for empty folders) - the expression input.folder || "all" evaluates to "all" for all three cases, but the query at lines 300-302 treats them differently, causing cache to return incorrect results
There was a problem hiding this comment.
Fixed in 3524cd0. The cache key now properly distinguishes between undefined (no filter → "all"), and null/empty string (no folder → "none"), so each filter state gets its own cache entry.
Additional Comments (1)
|
- Cache key now distinguishes between undefined (no filter), null/empty (no folder), avoiding incorrect cached results - Update endpoint normalizes empty string folder to null, consistent with create endpoint behavior Addresses Greptile review comments on PR databuddy-analytics#327
|
@greptile-apps Both issues addressed in 3524cd0:
Thanks for the thorough review! |
|
Perfect! Both fixes look solid:
The implementation is clean and the comment makes the intent clear. Thanks for the quick turnaround! |
|
Hi, just checking in - is there anything else needed for this PR? Happy to make any changes. |
Closes #271
Summary
Implements folder organization for feature flags as requested in the bounty issue.
Changes
Database Schema
API Endpoints
Implementation Details
auth/login,checkout/payment)Testing
Next Steps (UI Implementation)
This PR provides the backend foundation. UI implementation would include:
Notes