Skip to content
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

Fix category is/is not (nothing) filters #3669

Merged
merged 17 commits into from
Nov 20, 2024

Conversation

qedi-r
Copy link
Contributor

@qedi-r qedi-r commented Oct 14, 2024

Fixes #901, Fixes #904

This fixes up the category filtering when no category is selected. Transfers and split parents both have no category, so when a filter of no category is selected, the other two filters will be added to make it complete. Since transfers have to be specified, this also add support for filtering by is it a transfer or not.

Lastly, it looked like, in the compiler.ts the case for '$ne' NULL seemed incorrect, making the SQL X IS NULL just like the '$eq' NULL path. I would have expected '$ne' NULL to create the X IS NOT NULL, which was required to fix in order to find transactions that are or are not transfers.

@actual-github-bot actual-github-bot bot changed the title fix category is/is not (nothing) filters [WIP] fix category is/is not (nothing) filters Oct 14, 2024
Copy link

netlify bot commented Oct 14, 2024

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit 5b5afa5
🔍 Latest deploy log https://app.netlify.com/sites/actualbudget/deploys/673dc8df4620210008aaf55a
😎 Deploy Preview https://deploy-preview-3669.demo.actualbudget.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

github-actions bot commented Oct 14, 2024

Bundle Stats — desktop-client

Hey 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

Files count Total bundle size % Changed
10 5.42 MB → 5.42 MB (-36 B) -0.00%
Changeset
File Δ Size
home/runner/work/actual/actual/packages/loot-core/src/shared/rules.ts 📈 +187 B (+2.49%) 7.33 kB → 7.51 kB
src/components/filters/FiltersMenu.jsx 📈 +14 B (+0.11%) 12.55 kB → 12.56 kB
node_modules/define-data-property/index.js 📉 -9 B (-0.39%) 2.25 kB → 2.24 kB
node_modules/call-bind/index.js 📉 -9 B (-0.84%) 1.05 kB → 1.04 kB
node_modules/has-property-descriptors/index.js 📉 -9 B (-1.55%) 582 B → 573 B
node_modules/es-define-property/index.js 📉 -210 B (-37.50%) 560 B → 350 B
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

Asset File Size % Changed
static/js/AppliedFilters.js 21.3 kB → 21.32 kB (+14 B) +0.06%

Smaller

Asset File Size % Changed
static/js/index.js 3.44 MB → 3.44 MB (-50 B) -0.00%

Unchanged

Asset File Size % Changed
static/js/useAccountPreviewTransactions.js 1.63 kB 0%
static/js/indexeddb-main-thread-worker-e59fee74.js 13.5 kB 0%
static/js/resize-observer.js 18.37 kB 0%
static/js/BackgroundImage.js 122.29 kB 0%
static/js/workbox-window.prod.es5.js 5.69 kB 0%
static/js/narrow.js 82.72 kB 0%
static/js/wide.js 241.19 kB 0%
static/js/ReportRouter.js 1.49 MB 0%

Copy link
Contributor

github-actions bot commented Oct 14, 2024

Bundle Stats — loot-core

Hey 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

Files count Total bundle size % Changed
1 1.32 MB → 1.32 MB (+612 B) +0.04%
Changeset
File Δ Size
packages/loot-core/src/server/accounts/transaction-rules.ts 📈 +1.31 kB (+4.44%) 29.55 kB → 30.86 kB
packages/loot-core/src/shared/rules.ts 📈 +197 B (+1.99%) 9.69 kB → 9.88 kB
packages/loot-core/src/server/accounts/rules.ts 📈 +35 B (+0.11%) 31.9 kB → 31.93 kB
packages/loot-core/src/server/aql/compiler.ts 📈 +4 B (+0.01%) 35.38 kB → 35.39 kB
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

Asset File Size % Changed
kcab.worker.js 1.32 MB → 1.32 MB (+612 B) +0.04%

Smaller

No assets were smaller

Unchanged

No assets were unchanged

@qedi-r qedi-r changed the title [WIP] fix category is/is not (nothing) filters Fix category is/is not (nothing) filters Oct 14, 2024
Copy link
Contributor

coderabbitai bot commented Oct 14, 2024

Walkthrough

The pull request introduces several changes across multiple files to enhance the filtering capabilities of the application. In the FiltersMenu.jsx component, a new filter field named 'transfer' is added to the existing filterFields array, allowing users to filter transactions based on this category. In the transaction-rules.ts file, a new function called conditionSpecialCases is introduced, which handles specific conditions when the category field is null, and integrates with the existing conditionsToAQL function to include additional conditions. The compileOp function in compiler.ts is modified to improve the handling of the $ne operator when the right-hand side expression is null. Additionally, the FIELD_INFO constant in rules.ts is updated to include the new 'transfer' and 'parent' fields, both defined as boolean types. Finally, the FieldValueTypes type in rule.d.ts is updated to accommodate these new fields, ensuring the data structures reflect the expanded filtering options.

Assessment against linked issues

Objective Addressed Explanation
Add a “transfer” option to the category dropdown when filtering transactions (904)
Fix the issue with filtering where "category is (nothing)" displays transactions with category "Transfer" (901) The changes may address the issue but do not explicitly confirm the fix.

Possibly related PRs

Suggested labels

::sparkles: Merged

Suggested reviewers

  • youngcw

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

error Couldn't find any versions for "@typescript-eslint/types" that matches "8.15.0"
Error: Couldn't find any versions for "@typescript-eslint/types" that matches "8.15.0"
at MessageError.ExtendableBuiltin (/opt/yarn-v1.22.22/lib/cli.js:721:66)
at new MessageError (/opt/yarn-v1.22.22/lib/cli.js:750:123)
at Function. (/opt/yarn-v1.22.22/lib/cli.js:50353:13)
at Generator.next ()
at step (/opt/yarn-v1.22.22/lib/cli.js:310:30)
at /opt/yarn-v1.22.22/lib/cli.js:321:13
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
Error: Couldn't find any versions for "@typescript-eslint/types" that matches "8.15.0"
at MessageError.ExtendableBuiltin (/opt/yarn-v1.22.22/lib/cli.js:721:66)
at new MessageError (/opt/yarn-v1.22.22/lib/cli.js:750:123)
at Function. (/opt/yarn-v1.22.22/lib/cli.js:50353:13)
at Generator.next ()
at step (/opt/yarn-v1.22.22/lib/cli.js:310:30)
at /opt/yarn-v1.22.22/lib/cli.js:321:13
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
Error: Couldn't find any versions for "@typescript-eslint/types" that matches "8.15.0"
at MessageError.ExtendableBuiltin (/opt/yarn-v1.22.22/lib/cli.js:721:66)
at new MessageError (/opt/yarn-v1.22.22/lib/cli.js:750:123)
at Function. (/opt/yarn-v1.22.22/lib/cli.js:50353:13)
at Generator.next ()
at step (/opt/yarn-v1.22.22/lib/cli.js:310:30)
at /opt/yarn-v1.22.22/lib/cli.js:321:13
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between bf9fcdc and 5b5afa5.

📒 Files selected for processing (1)
  • packages/desktop-client/src/components/filters/FiltersMenu.jsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/desktop-client/src/components/filters/FiltersMenu.jsx

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

🧹 Outside diff range and nitpick comments (4)
packages/loot-core/src/shared/rules.ts (1)

72-73: LGTM! Consider adding documentation for the parent field.

The addition of transfer and parent fields to FIELD_INFO is correct and aligns with the PR objectives. Both fields are properly typed as boolean.

The transfer field clearly supports the new filtering capability for transfer transactions. However, the purpose of the parent field is not immediately clear from the PR objectives or surrounding context.

Consider adding a comment to explain the purpose and usage of the parent field for better maintainability.

packages/desktop-client/src/components/filters/FiltersMenu.jsx (1)

57-57: LGTM! Consider enhancing readability with a comment.

The addition of 'transfer' to the filterFields array is correct and aligns with the PR objectives. It enables filtering transactions based on whether they are transfers or not.

Consider adding a brief comment above the filterFields array to explain its purpose and the significance of the order, if any. This would enhance code readability and maintainability. For example:

// Define filter fields in order of appearance in the UI
const filterFields = [
  'date',
  'account',
  // ... other fields ...
  'transfer',
].map(field => [field, mapField(field)]);
packages/loot-core/src/server/aql/compiler.ts (1)

697-697: Consider updating documentation and communicating this change

While this fix correctly implements the $ne operator for NULL comparisons, it's important to note that this change might affect existing queries that relied on the previous (incorrect) behavior. To ensure a smooth transition:

  1. Update any relevant documentation to reflect this change in NULL handling.
  2. Consider adding a note in the changelog or release notes about this behavior change.
  3. If possible, analyze existing queries in the system to identify any that might be affected by this change and plan for their updates.

This change aligns the behavior with SQL standards, which should improve consistency and reduce confusion for users familiar with SQL.

packages/loot-core/src/server/accounts/transaction-rules.ts (1)

344-360: Consider adding comments to clarify condition remapping logic

The remapping of field, op, and value for 'transfer' and 'parent' conditions is functionally correct but may not be immediately intuitive. Adding explanatory comments could improve readability and help future maintainers understand the rationale behind these transformations.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between b253246 and bf9fcdc.

⛔ Files ignored due to path filters (1)
  • upcoming-release-notes/3669.md is excluded by !**/*.md
📒 Files selected for processing (5)
  • packages/desktop-client/src/components/filters/FiltersMenu.jsx (1 hunks)
  • packages/loot-core/src/server/accounts/transaction-rules.ts (3 hunks)
  • packages/loot-core/src/server/aql/compiler.ts (1 hunks)
  • packages/loot-core/src/shared/rules.ts (1 hunks)
  • packages/loot-core/src/types/models/rule.d.ts (1 hunks)
🧰 Additional context used
🔇 Additional comments (4)
packages/loot-core/src/types/models/rule.d.ts (1)

40-41: LGTM! Please clarify the purpose of the parent field.

The addition of the transfer field aligns well with the PR objectives, specifically addressing Issue #904 by enabling filtering of transfer transactions. This change enhances the application's filtering capabilities as intended.

The parent field, while a logical addition to the FieldValueTypes, is not explicitly mentioned in the PR objectives or linked issues. Could you please provide some context on its purpose and how it relates to the overall enhancements being made?

To ensure these changes are properly utilized, let's check for their usage in the codebase:

packages/loot-core/src/server/aql/compiler.ts (1)

697-697: Excellent fix for the $ne NULL comparison!

This change correctly implements the $ne (not equal) operator when comparing with NULL. It now returns IS NOT NULL instead of IS NULL, which aligns with the SQL standard and fixes the logical error in the previous implementation. This adjustment ensures that X != NULL is correctly interpreted as X IS NOT NULL, addressing the issue mentioned in the PR objectives.

To ensure this change doesn't introduce any regressions, let's verify its usage:

packages/loot-core/src/server/accounts/transaction-rules.ts (2)

293-309: Well-implemented handling of special cases in conditionSpecialCases

The new conditionSpecialCases function effectively manages special cases where the category field is null. It correctly expands these conditions to include checks for 'transfer' and 'parent', enhancing the accuracy of condition processing.


329-329: Appropriate integration of special conditions using .flatMap

The addition of .flatMap(conditionSpecialCases) integrates the special case conditions seamlessly into the condition processing pipeline. This ensures that all expanded conditions are considered before filtering, improving the overall logic flow.

@youngcw youngcw added this to the v24.11.0 milestone Oct 15, 2024
@youngcw youngcw modified the milestones: v24.11.0, v24.12.0 Oct 23, 2024
@qedi-r
Copy link
Contributor Author

qedi-r commented Nov 2, 2024

Sorry, been away and didn't notice the last change had a lint error. Fixed.

UnderKoen
UnderKoen previously approved these changes Nov 3, 2024
@matt-fidd
Copy link
Contributor

/update-vrt

3 similar comments
@matt-fidd
Copy link
Contributor

/update-vrt

@matt-fidd
Copy link
Contributor

/update-vrt

@matt-fidd
Copy link
Contributor

/update-vrt

@matt-fidd
Copy link
Contributor

Hey @qedi-r, is it okay for me to apply the requested change so we can get this merged in? It'd be great to have in for the next release.

Yes, sorry! I though i clicked that button already.

Sorry, it won't let me! Would you mind trying/making the change on your end and pushing please?

@qedi-r
Copy link
Contributor Author

qedi-r commented Nov 19, 2024

Ok. I will have to tonight though.

@matt-fidd
Copy link
Contributor

Ok. I will have to tonight though.

Of course! No problem, whenever you get a chance.

@matt-fidd
Copy link
Contributor

Don't worry, I found a way to do it

@matt-fidd matt-fidd force-pushed the u/qedi-r/category-none branch from 47b3b38 to 5b5afa5 Compare November 20, 2024 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants