[PR #4652] [MERGED] refactor: improve type option filter logic #6368

Closed
opened 2026-03-23 22:22:55 +00:00 by mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/AppFlowy-IO/AppFlowy/pull/4652
Author: @richardshiue
Created: 2/14/2024
Status: Merged
Merged: 2/21/2024
Merged by: @appflowy

Base: mainHead: refactor/filter-strategy


📝 Commits (1)

  • e6c232d refactor: improve type option filter logic

📊 Changes

7 files changed (+189 additions, -110 deletions)

View changed files

📝 frontend/rust-lib/flowy-database2/src/entities/filter_entities/date_filter.rs (+1 -2)
📝 frontend/rust-lib/flowy-database2/src/entities/filter_entities/number_filter.rs (+1 -2)
📝 frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_filter.rs (+120 -63)
📝 frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_type_option.rs (+1 -5)
📝 frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/number_filter.rs (+61 -29)
📝 frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/number_type_option.rs (+2 -5)
📝 frontend/rust-lib/flowy-database2/src/services/field/type_options/timestamp_type_option/timestamp_type_option.rs (+3 -4)

📄 Description

  • match the condition in the <type>FilterPB first, not the arguments given. e.g. before, it first sees that the timestamp on a DateFilterPB is None, then deduces that the condition will be either IsEmpty or IsNotEmpty.
  • this improves readability, and especially inDateFilterPB where the logic for DateConditionPB::IsWithin isn't immediately apparent.
  • this also tests that the arguments are correct, catching when appropriate arguments aren't present in the passed-in <type>FilterPB.

Feature Preview


PR Checklist

  • My code adheres to AppFlowy's Conventions
  • I've listed at least one issue that this PR fixes in the description above.
  • I've added a test(s) to validate changes in this PR, or this PR only contains semantic changes.
  • All existing tests are passing.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/AppFlowy-IO/AppFlowy/pull/4652 **Author:** [@richardshiue](https://github.com/richardshiue) **Created:** 2/14/2024 **Status:** ✅ Merged **Merged:** 2/21/2024 **Merged by:** [@appflowy](https://github.com/appflowy) **Base:** `main` ← **Head:** `refactor/filter-strategy` --- ### 📝 Commits (1) - [`e6c232d`](https://github.com/AppFlowy-IO/AppFlowy/commit/e6c232d6a7956865e1b6b375fdbcd712b633a788) refactor: improve type option filter logic ### 📊 Changes **7 files changed** (+189 additions, -110 deletions) <details> <summary>View changed files</summary> 📝 `frontend/rust-lib/flowy-database2/src/entities/filter_entities/date_filter.rs` (+1 -2) 📝 `frontend/rust-lib/flowy-database2/src/entities/filter_entities/number_filter.rs` (+1 -2) 📝 `frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_filter.rs` (+120 -63) 📝 `frontend/rust-lib/flowy-database2/src/services/field/type_options/date_type_option/date_type_option.rs` (+1 -5) 📝 `frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/number_filter.rs` (+61 -29) 📝 `frontend/rust-lib/flowy-database2/src/services/field/type_options/number_type_option/number_type_option.rs` (+2 -5) 📝 `frontend/rust-lib/flowy-database2/src/services/field/type_options/timestamp_type_option/timestamp_type_option.rs` (+3 -4) </details> ### 📄 Description - match the condition in the `<type>FilterPB` first, not the arguments given. e.g. before, it first sees that the timestamp on a `DateFilterPB` is `None`, then deduces that the condition will be either `IsEmpty` or `IsNotEmpty`. - this improves readability, and especially in`DateFilterPB` where the logic for `DateConditionPB::IsWithin` isn't immediately apparent. - this also tests that the arguments are correct, catching when appropriate arguments aren't present in the passed-in `<type>FilterPB`. ### Feature Preview <!--- List at least one issue here that this PR addresses. If it fixes the issue, please use the [fixes](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests) keyword to close the issue. For example: fixes https://github.com/AppFlowy-IO/AppFlowy/pull/2106 --> --- <!--- Before you mark this PR ready for review, run through this checklist! --> #### PR Checklist - [x] My code adheres to [AppFlowy's Conventions](https://docs.appflowy.io/docs/documentation/software-contributions/conventions) - [ ] I've listed at least one issue that this PR fixes in the description above. - [ ] I've added a test(s) to validate changes in this PR, or this PR only contains semantic changes. - [ ] All existing tests are passing. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
mirror 2026-03-23 22:22:55 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
AppFlowy-IO/AppFlowy#6368
No description provided.