cube icon indicating copy to clipboard operation
cube copied to clipboard

fix: move from/to parsing to the very top

Open tsaplev opened this issue 1 week ago • 2 comments

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.

tsaplev avatar Jun 25 '24 10:06 tsaplev