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: move from/to parsing to the very top #8389

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tsaplev
Copy link

@tsaplev tsaplev commented Jun 25, 2024

According to the documentation, there's an option to use the syntax "from ... to ..." for dateRange, which uses the Chrono library under the hood.

My intention is to get a relative dateRange for the entire week a week ago. The prompt I use is from (14 days before this week) to (7 days before this week). If I put the prompt into Chrono standalone, it works perfectly and returns the dates I expect. However, Cube processes it differently — it only returns the date range for "last week" and ignores the rest of the prompt.

I investigated the source code and realised this issue occurs because of the order of conditions in dateParser.js. If a prompt contains "this week", "this month", "this day", etc., only this part will be handled, and the rest will be ignored. My proposal in this PR is to move the "from / to" condition to the very top, ensuring that 'from / to' will also be handled if they contain "this week", "this month", "this day", etc.

According to the documentation, there's an option to use the syntax "from ... to ..." for dateRange, which uses the Chrono library under the hood.

My intention is to get a relative dateRange for the entire week a week ago. The prompt I use is `from (14 days before this week) to (7 days before this week)`. If I put the prompt into Chrono standalone, it works perfectly and returns the dates I expect. However, Cube processes it differently — it only returns the date range for "last week" and ignores the rest of the prompt.

I investigated the source code and realized this issue occurs because of the order of conditions in `dateParser.js`. If a prompt contains "this week", "this month", "this day", etc., only this part will be handled, and the rest will be ignored. My proposal in this PR is to move the "from / to" condition to the very top, ensuring that 'from / to' will also be handled if they contain "this week", "this month", "this day", etc.
@tsaplev tsaplev requested a review from a team as a code owner June 25, 2024 10:13
Copy link

vercel bot commented Jun 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

8 Ignored Deployments
Name Status Preview Comments Updated (UTC)
examples-angular-dashboard ⬜️ Ignored (Inspect) Visit Preview Jun 25, 2024 10:14am
examples-react-d3 ⬜️ Ignored (Inspect) Visit Preview Jun 25, 2024 10:14am
examples-react-dashboard ⬜️ Ignored (Inspect) Visit Preview Jun 25, 2024 10:14am
examples-react-data-table ⬜️ Ignored (Inspect) Visit Preview Jun 25, 2024 10:14am
examples-react-highcharts ⬜️ Ignored (Inspect) Visit Preview Jun 25, 2024 10:14am
examples-react-material-ui ⬜️ Ignored (Inspect) Visit Preview Jun 25, 2024 10:14am
examples-react-pivot-table ⬜️ Ignored (Inspect) Visit Preview Jun 25, 2024 10:14am
examples-vue-query-builder ⬜️ Ignored (Inspect) Visit Preview Jun 25, 2024 10:14am
@github-actions github-actions bot added the pr:community Contribution from Cube.js community members. label Jun 25, 2024
@tsaplev tsaplev marked this pull request as draft June 25, 2024 10:16
@igorlukanin
Copy link
Member

igorlukanin commented Jun 25, 2024

Thanks for your PR @tsaplev 🙌

While this change generally makes sense to me, I believe applying it will be a breaking change since other Cube users might already depend on the particular order of relative date rules resolution. So, we would need to do at least a minor release if we merge this changes. I'll let @paveltiunov to chime in here as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:community Contribution from Cube.js community members.
3 participants