Fix date query handler to use 1-based month/day and add regression test#8213
Open
KAVYANSHTYAGI wants to merge 1 commit intoAppFlowy-IO:mainfrom
Open
Fix date query handler to use 1-based month/day and add regression test#8213KAVYANSHTYAGI wants to merge 1 commit intoAppFlowy-IO:mainfrom
KAVYANSHTYAGI wants to merge 1 commit intoAppFlowy-IO:mainfrom
Conversation
Contributor
Reviewer's guide (collapsed on small PRs)Reviewer's GuideFix date query handler to use 1-based month/day indexing and bolster test coverage with an async regression test Sequence diagram for date query handling with year substitutionsequenceDiagram
participant "AFPluginData"
participant "query_date_handler()"
participant "NaiveDate"
participant "FlowyError"
"AFPluginData"->>"query_date_handler()": pass query (e.g., "June 5 2024")
"query_date_handler()"->>"NaiveDate": extract month() and day() (1-based)
"query_date_handler()"->>"NaiveDate": from_ymd_opt(year, month, day)
alt valid date
"NaiveDate"-->>"query_date_handler()": formatted date string
else invalid date
"query_date_handler()"->>"FlowyError": fallback to original date string
end
"query_date_handler()"-->>"AFPluginData": return result
Class diagram for updated date query handler and testclassDiagram
class DateQueryPB {
+String query
}
class AFPluginData {
+DateQueryPB inner
}
class FlowyError {
+internal()
+with_context(str)
}
class NaiveDate {
+from_ymd_opt(year: i32, month: u32, day: u32)
+month()
+day()
+to_string()
}
class query_date_handler {
+async fn query_date_handler(AFPluginData) -> Result
}
class tests {
+async fn parses_year_from_query()
}
AFPluginData --> DateQueryPB
query_date_handler --> AFPluginData
query_date_handler --> NaiveDate
query_date_handler --> FlowyError
tests --> query_date_handler
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Description
This PR addresses a bug in the date query handler where NaiveDate::from_ymd_opt was constructed with month0()/day0(), leading to invalid or missing dates when substituting a parsed year.
Changes
Notes
Summary by Sourcery
Fix the date query handler to use 1-based month and day in NaiveDate construction and add a regression test to verify correct year parsing.
Bug Fixes:
Tests: