Skip to content
Snippets Groups Projects
Commit c2492cc7 authored by Tom Robinson's avatar Tom Robinson
Browse files

Merge branch 'implement-6443' of github.com:metabase/metabase into implement-6443

parents 599f20d2 647061f7
Branches
Tags
No related merge requests found
......@@ -109,12 +109,15 @@
:end (t/minus dt (t/days 1))})
:filter (fn [_ field] ["=" field ["relative_datetime" -1 "day"]])}
{:parser (regex->parser #"past([0-9]+)(day|week|month|year)s", [:int-value :unit])
;; adding a tilde (~) at the end of a past<n><unit> filter means we should include the current day/etc.
;; e.g. past30days = past 30 days, not including partial data for today ({:include-current false})
;; past30days~ = past 30 days, *including* partial data for today ({:include-current true})
{:parser (regex->parser #"past([0-9]+)(day|week|month|year)s(~?)", [:int-value :unit :include-current?])
:range (fn [{:keys [unit int-value unit-range to-period]} dt]
(unit-range (t/minus dt (to-period int-value))
(t/minus dt (to-period 1))))
:filter (fn [{:keys [unit int-value]} field]
["TIME_INTERVAL" field (- int-value) unit])}
:filter (fn [{:keys [unit int-value include-current?]} field]
["TIME_INTERVAL" field (- int-value) unit {:include-current (boolean (seq include-current?))}])}
{:parser (regex->parser #"next([0-9]+)(day|week|month|year)s" [:int-value :unit])
:range (fn [{:keys [unit int-value unit-range to-period]} dt]
......
......@@ -53,7 +53,7 @@
(expect
{:database 1
:type :query
:query {:filter ["TIME_INTERVAL" ["field-id" 123] -30 "day"]
:query {:filter ["TIME_INTERVAL" ["field-id" 123] -30 "day" {:include-current false}]
:breakout [17]}}
(expand-parameters {:database 1
:type :query
......@@ -64,6 +64,20 @@
:target ["dimension" ["field-id" 123]]
:value "past30days"}]}))
(expect
{:database 1
:type :query
:query {:filter ["TIME_INTERVAL" ["field-id" 123] -30 "day" {:include-current true}]
:breakout [17]}}
(expand-parameters {:database 1
:type :query
:query {:breakout [17]}
:parameters [{:hash "abc123"
:name "foo"
:type "date"
:target ["dimension" ["field-id" 123]]
:value "past30days~"}]}))
(expect
{:database 1
:type :query
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment