-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spending Report: Fix budget category filtering #4194
Spending Report: Fix budget category filtering #4194
Conversation
- Previously only worked for category *is*, now should work for any category filters
✅ Deploy Preview for actualbudget ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Bundle Stats — desktop-clientHey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle. As this PR is updated, I'll keep you updated on how the bundle size is impacted. Total
Changeset
View detailed bundle breakdownAdded No assets were added Removed No assets were removed Bigger
Smaller No assets were smaller Unchanged
|
Bundle Stats — loot-coreHey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle. As this PR is updated, I'll keep you updated on how the bundle size is impacted. Total
Changeset
View detailed bundle breakdownAdded No assets were added Removed No assets were removed Bigger
Smaller No assets were smaller Unchanged No assets were unchanged |
…r options - Removed ability to select 'contains', 'doesNotContain', or 'matches' filters for budget categories
WalkthroughThe pull request introduces modifications to the Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/desktop-client/src/components/reports/spreadsheets/spending-spreadsheet.ts (2)
49-59
: LGTM! Consider adding type annotations for better type safety.The implementation correctly handles budget category filtering by excluding incompatible operations ('contains', 'doesNotContain', 'matches') and restricting to category fields, which aligns with the PR objectives.
Consider adding type annotations for the destructured
filters
object:- const { filters: budgetFilters } = await send( + const { filters: budgetFilters }: { filters: typeof filters } = await send(
Line range hint
48-125
: Well-structured implementation with good separation of concerns.The architectural approach of separating budget-specific filters from general filters is clean and maintainable. This separation:
- Allows for different filter operations between budgets and transactions
- Makes it easier to add support for additional filter types in the future
- Maintains clear boundaries between different filtering concerns
The implementation aligns well with the existing patterns in the codebase.
Consider documenting these architectural decisions in the codebase to help future maintainers understand the reasoning behind the separate filtering mechanisms.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
upcoming-release-notes/4194.md
is excluded by!**/*.md
📒 Files selected for processing (1)
packages/desktop-client/src/components/reports/spreadsheets/spending-spreadsheet.ts
(2 hunks)
🧰 Additional context used
📓 Learnings (1)
packages/desktop-client/src/components/reports/spreadsheets/spending-spreadsheet.ts (1)
Learnt from: jfdoming
PR: actualbudget/actual#4146
File: packages/desktop-client/src/components/reports/spreadsheets/summary-spreadsheet.ts:30-30
Timestamp: 2025-01-14T06:17:55.345Z
Learning: The `make-filters-from-conditions` function in the Actual Budget codebase returns a complex type that is not explicitly defined. While improving its type definition would be beneficial, it should be handled in a dedicated project due to its complexity.
🔇 Additional comments (1)
packages/desktop-client/src/components/reports/spreadsheets/spending-spreadsheet.ts (1)
125-125
: LGTM! Verify query behavior with different filter combinations.The implementation correctly applies the budget-specific filters to the zero_budgets query while maintaining consistency with the existing query structure.
Let's verify the query behavior with different filter combinations:
✅ Verification successful
Implementation verified - follows established query patterns
The budget filter implementation follows the same query structure used consistently across all report types in the codebase, integrating correctly with the core query system in
makeQuery.ts
. The pattern of usingconditionsOp
with filters is well-established and verified in multiple spreadsheet implementations.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Search for tests covering different budget filter combinations # Look for test files related to spending reports fd -e test.ts -e test.tsx -e spec.ts -e spec.tsx . | grep -i "spend" # Search for budget filter test cases rg -l "zero_budgets.*filter" # Look for filter condition combinations in test files rg "conditions.*category.*(?:oneOf|not in|is)" -A 5Length of output: 153
Script:
#!/bin/bash # Search for the specific file and related test files fd "spending-spreadsheet" . # Look for similar query patterns in the codebase rg -l "conditionsOp.*filters" . # Search for budget-related query implementations ast-grep --pattern 'budgetFilters = $_' # Look for test files with query conditions rg -l "conditions.*filters?" packages/Length of output: 5420
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, I changed the database schema for you so it allows the join. Could you verify it still works as expected? Than I'm happy to merge this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/loot-core/src/server/aql/schema/index.ts (1)
Line range hint
169-178
: Consider aligning schema definitions between budget tables.The
reflect_budgets
table usescategory: f('string')
whilezero_budgets
now usescategory: f('string', { ref: 'categories' })
. This inconsistency could lead to data integrity issues.Consider applying the same foreign key reference to the
reflect_budgets
table:reflect_budgets: { id: f('id'), month: f('integer'), - category: f('string'), + category: f('string', { ref: 'categories' }), amount: f('integer'), carryover: f('integer'), goal: f('integer'), long_goal: f('integer'), },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/desktop-client/src/components/reports/spreadsheets/spending-spreadsheet.ts
(2 hunks)packages/loot-core/src/server/aql/schema/index.ts
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/desktop-client/src/components/reports/spreadsheets/spending-spreadsheet.ts
⏰ Context from checks skipped due to timeout of 90000ms (5)
- GitHub Check: build (macos-latest)
- GitHub Check: Wait for Netlify build to finish
- GitHub Check: build (windows-latest)
- GitHub Check: build (ubuntu-latest)
- GitHub Check: Analyze
🔇 Additional comments (1)
packages/loot-core/src/server/aql/schema/index.ts (1)
172-172
: Verify data integrity before applying the schema change.Adding a foreign key reference to the
categories
table is a good improvement that enforces data integrity. However, this is a breaking schema change that requires careful consideration.Please ensure:
- Existing
zero_budgets
records have valid category references- A database migration plan is in place
- The application handles the case of deleted categories gracefully
Run this script to verify existing data integrity:
✅ Verification successful
Schema change is safe to proceed
The codebase analysis reveals:
- Robust category deletion handling with proper transfer mechanisms
- Read-only operations on zero_budgets table
- Existing migration infrastructure to handle schema changes
The foreign key reference addition aligns with the existing data integrity patterns and can be safely implemented through the migration system.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for orphaned categories in zero_budgets table # Expected: No output if all categories are valid # Search for any direct SQL queries or schema definitions that might be affected rg -A 3 "zero_budgets.*category|category.*zero_budgets" # Search for existing migrations fd -g "*migration*.{ts,js,sql}"Length of output: 1293
Script:
#!/bin/bash # Check migrations and category operations # 1. Examine migrations content cat packages/loot-core/src/server/migrate/migrations.ts # 2. Look for category deletion handling rg -A 5 "deleteCategory|removeCat|category.*delete|delete.*category" # 3. Find INSERT/UPDATE operations on zero_budgets rg -A 3 "INSERT INTO zero_budgets|UPDATE zero_budgets"Length of output: 38045
Thanks, I didn't realize it would be that simple to update the schema! Your changes work perfectly in my testing |
Fixes up the Spending Report category filters when comparing to the budget. Previously only worked for the category is filter. Now added support for other category filters (one of, not in, etc.)
Note that this does not fix the filters for
contains
,matches
, ordoes not contain
since they seem to create incompatible joins on the zero_budgets table so I'm simply filtering these options out for now.Fixes #4044