Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Prepare for graph v2 (#4451)
RobertJoonas039790b82d01
diff --git a/assets/js/dashboard/stats/graph/date-formatter.js b/assets/js/dashboard/stats/graph/date-formatter.jsindex 1f94720bae..2d3a5def4a 100644--- a/assets/js/dashboard/stats/graph/date-formatter.js+++ b/assets/js/dashboard/stats/graph/date-formatter.js@@ -26,7 +26,7 @@ const weekIntervalFormatter = {}}-const dateIntervalFormatter = {+const dayIntervalFormatter = {long(isoDate, _options) {return parseUTCDate(isoDate).format('ddd, D MMM')},@@ -74,7 +74,7 @@ const minuteIntervalFormatter = {const factory = {month: monthIntervalFormatter,week: weekIntervalFormatter,- date: dateIntervalFormatter,+ day: dayIntervalFormatter,hour: hourIntervalFormatter,minute: minuteIntervalFormatter}diff --git a/assets/js/dashboard/stats/graph/graph-tooltip.js b/assets/js/dashboard/stats/graph/graph-tooltip.jsindex 1763d7bb72..f6536d2a43 100644--- a/assets/js/dashboard/stats/graph/graph-tooltip.js+++ b/assets/js/dashboard/stats/graph/graph-tooltip.js@@ -16,7 +16,7 @@ const renderBucketLabel = function(query, graphData, label, comparison = false)}if (graphData.interval === 'hour' || graphData.interval == 'minute') {- const date = dateFormatter({ interval: "date", longForm: true, period: query.period })(label)+ const date = dateFormatter({ interval: "day", longForm: true, period: query.period })(label)return `${date}, ${formattedLabel}`}@@ -113,7 +113,7 @@ export default function GraphTooltip(graphData, metric, query) {</div>${graphData.interval === "month" ? `<span class="font-semibold italic">Click to view month</span>` : ""}- ${graphData.interval === "date" ? `<span class="font-semibold italic">Click to view day</span>` : ""}+ ${graphData.interval === "day" ? `<span class="font-semibold italic">Click to view day</span>` : ""}</aside>`}diff --git a/assets/js/dashboard/stats/graph/interval-picker.js b/assets/js/dashboard/stats/graph/interval-picker.jsindex 26cbb5c1cc..c201cfbf10 100644--- a/assets/js/dashboard/stats/graph/interval-picker.js+++ b/assets/js/dashboard/stats/graph/interval-picker.js@@ -10,7 +10,7 @@ import { useSiteContext } from '../../site-context';const INTERVAL_LABELS = {'minute': 'Minutes','hour': 'Hours',- 'date': 'Days',+ 'day': 'Days','week': 'Weeks','month': 'Months'}@@ -18,11 +18,11 @@ const INTERVAL_LABELS = {function validIntervals(site, query) {if (query.period === 'custom') {if (query.to.diff(query.from, 'days') < 7) {- return ['date']+ return ['day']} else if (query.to.diff(query.from, 'months') < 1) {- return ['date', 'week']+ return ['day', 'week']} else if (query.to.diff(query.from, 'months') < 12) {- return ['date', 'week', 'month']+ return ['day', 'week', 'month']} else {return ['week', 'month']}@@ -34,7 +34,7 @@ function validIntervals(site, query) {function getDefaultInterval(query, validIntervals) {const defaultByPeriod = {'day': 'hour',- '7d': 'date',+ '7d': 'day','6mo': 'month','12mo': 'month','year': 'month'@@ -49,7 +49,7 @@ function getDefaultInterval(query, validIntervals) {function defaultForCustomPeriod(from, to) {if (to.diff(from, 'days') < 30) {- return 'date'+ return 'day'} else if (to.diff(from, 'months') < 6) {return 'week'} else {@@ -58,7 +58,13 @@ function defaultForCustomPeriod(from, to) {}function getStoredInterval(period, domain) {- return storage.getItem(`interval__${period}__${domain}`)+ const stored = storage.getItem(`interval__${period}__${domain}`)++ if (stored === 'date') {+ return 'day'+ } else {+ return stored+ }}function storeInterval(period, domain, interval) {diff --git a/assets/js/dashboard/stats/graph/line-graph.js b/assets/js/dashboard/stats/graph/line-graph.jsindex 36736d8797..f4f93dfc41 100644--- a/assets/js/dashboard/stats/graph/line-graph.js+++ b/assets/js/dashboard/stats/graph/line-graph.js@@ -106,7 +106,7 @@ class LineGraph extends React.Component {if (graphData.interval === 'hour' && query.period !== 'day') {const date = dateFormatter({- interval: "date",+ interval: "day",longForm: false,period: query.period,shouldShowYear: hasMultipleYears,@@ -227,7 +227,7 @@ class LineGraph extends React.Component {if (this.props.graphData.interval === 'month') {navigateToQuery(this.props.navigate, this.props.query, { period: 'month', date })- } else if (this.props.graphData.interval === 'date') {+ } else if (this.props.graphData.interval === 'day') {navigateToQuery(this.props.navigate, this.props.query, { period: 'day', date })}}diff --git a/assets/js/dashboard/stats/graph/visitor-graph.js b/assets/js/dashboard/stats/graph/visitor-graph.jsindex 7fc84be3fa..5516d8f2e3 100644--- a/assets/js/dashboard/stats/graph/visitor-graph.js+++ b/assets/js/dashboard/stats/graph/visitor-graph.js@@ -160,7 +160,10 @@ export default function VisitorGraph({ updateImportedDataInView }) {}<IntervalPicker onIntervalUpdate={onIntervalUpdate} /></div>- <LineGraphWithRouter graphData={graphData} darkTheme={isDarkTheme} />+ <LineGraphWithRouter+ graphData={{...graphData, interval: getCurrentInterval(site, query)}}+ darkTheme={isDarkTheme}+ /></div></FadeIn></div>diff --git a/lib/plausible/stats/filters/query_parser.ex b/lib/plausible/stats/filters/query_parser.exindex 6882b88570..a7c3c9ab04 100644--- a/lib/plausible/stats/filters/query_parser.ex+++ b/lib/plausible/stats/filters/query_parser.ex@@ -11,11 +11,10 @@ defmodule Plausible.Stats.Filters.QueryParser dotime_labels: false}- def parse(site, params, now \\ nil) when is_map(params) do+ def parse(site, params) when is_map(params) dowith {:ok, metrics} <- parse_metrics(Map.get(params, "metrics", [])),{:ok, filters} <- parse_filters(Map.get(params, "filters", [])),- {:ok, date_range} <-- parse_date_range(site, Map.get(params, "date_range"), now || today(site)),+ {:ok, date_range} <- parse_date_range(site, Map.take(params, ["date_range", "date"])),{:ok, dimensions} <- parse_dimensions(Map.get(params, "dimensions", [])),{:ok, order_by} <- parse_order_by(Map.get(params, "order_by")),{:ok, include} <- parse_include(Map.get(params, "include", %{})),@@ -116,6 +115,23 @@ defmodule Plausible.Stats.Filters.QueryParser dodefp parse_clauses_list(filter), do: {:error, "Invalid filter '#{inspect(filter)}'"}+ defp parse_date_range(site, %{"date_range" => date_range, "date" => date})+ when is_binary(date) do+ case Date.from_iso8601(date) do+ {:ok, date} -> parse_date_range(site, date_range, date)+ _ -> {:error, "Invalid date '#{date}'"}+ end+ end++ defp parse_date_range(site, %{"date_range" => date_range, "date" => date})+ when is_struct(date) do+ parse_date_range(site, date_range, date)+ end++ defp parse_date_range(site, %{"date_range" => date_range}) do+ parse_date_range(site, date_range, today(site))+ end+defp parse_date_range(_site, "day", date) do{:ok, Date.range(date, date)}enddiff --git a/lib/plausible/stats/interval.ex b/lib/plausible/stats/interval.exindex 116f711c99..eb501adf75 100644--- a/lib/plausible/stats/interval.ex+++ b/lib/plausible/stats/interval.ex@@ -3,7 +3,7 @@ defmodule Plausible.Stats.Interval doCollection of functions to work with intervals.The interval of a query defines the granularity of the data. You can think of- it as a `GROUP BY` clause. Possible values are `minute`, `hour`, `date`,+ it as a `GROUP BY` clause. Possible values are `minute`, `hour`, `day`,`week`, and `month`."""@@ -12,7 +12,7 @@ defmodule Plausible.Stats.Interval do@type opts :: list(opt())@typep period() :: String.t()- @intervals ~w(minute hour date week month)+ @intervals ~w(minute hour day week month)@spec list() :: [t()]def list, do: @intervals@@ -29,7 +29,7 @@ defmodule Plausible.Stats.Interval docase period do"realtime" -> "minute""day" -> "hour"- period when period in ["custom", "7d", "30d", "month"] -> "date"+ period when period in ["custom", "7d", "30d", "month"] -> "day"period when period in ["6mo", "12mo", "year"] -> "month"endend@@ -44,7 +44,7 @@ defmodule Plausible.Stats.Interval do"month"Timex.diff(last, first, :days) > 0 ->- "date"+ "day"true ->"hour"@@ -54,14 +54,14 @@ defmodule Plausible.Stats.Interval do@valid_by_period %{"realtime" => ["minute"],"day" => ["minute", "hour"],- "7d" => ["hour", "date"],- "month" => ["date", "week"],- "30d" => ["date", "week"],- "6mo" => ["date", "week", "month"],- "12mo" => ["date", "week", "month"],- "year" => ["date", "week", "month"],- "custom" => ["date", "week", "month"],- "all" => ["date", "week", "month"]+ "7d" => ["hour", "day"],+ "month" => ["day", "week"],+ "30d" => ["day", "week"],+ "6mo" => ["day", "week", "month"],+ "12mo" => ["day", "week", "month"],+ "year" => ["day", "week", "month"],+ "custom" => ["day", "week", "month"],+ "all" => ["day", "week", "month"]}@spec valid_by_period(opts()) :: map()diff --git a/lib/plausible/stats/time.ex b/lib/plausible/stats/time.exindex a9520c5b61..f87c40e4ed 100644--- a/lib/plausible/stats/time.ex+++ b/lib/plausible/stats/time.ex@@ -10,11 +10,13 @@ defmodule Plausible.Stats.Time dolast_datetime =now|> NaiveDateTime.shift(second: 5)- |> beginning_of_time(site.native_stats_start_at)|> NaiveDateTime.truncate(:second)first_datetime =- now |> NaiveDateTime.shift(minute: -5) |> NaiveDateTime.truncate(:second)+ now+ |> NaiveDateTime.shift(minute: -5)+ |> NaiveDateTime.truncate(:second)+ |> beginning_of_time(site.native_stats_start_at){first_datetime, last_datetime}end@@ -23,11 +25,13 @@ defmodule Plausible.Stats.Time dolast_datetime =now|> NaiveDateTime.shift(second: 5)- |> beginning_of_time(site.native_stats_start_at)|> NaiveDateTime.truncate(:second)first_datetime =- now |> NaiveDateTime.shift(minute: -30) |> NaiveDateTime.truncate(:second)+ now+ |> NaiveDateTime.shift(minute: -30)+ |> NaiveDateTime.truncate(:second)+ |> beginning_of_time(site.native_stats_start_at){first_datetime, last_datetime}enddiff --git a/lib/plausible/stats/timeseries.ex b/lib/plausible/stats/timeseries.exindex e1f5d73779..8b3ddbcc38 100644--- a/lib/plausible/stats/timeseries.ex+++ b/lib/plausible/stats/timeseries.ex@@ -12,7 +12,7 @@ defmodule Plausible.Stats.Timeseries do@time_dimension %{"month" => "time:month","week" => "time:week",- "date" => "time:day",+ "day" => "time:day","hour" => "time:hour","minute" => "time:minute"}diff --git a/lib/plausible_web/controllers/api/external_stats_controller.ex b/lib/plausible_web/controllers/api/external_stats_controller.exindex fa3188550d..2561878752 100644--- a/lib/plausible_web/controllers/api/external_stats_controller.ex+++ b/lib/plausible_web/controllers/api/external_stats_controller.ex@@ -259,6 +259,13 @@ defmodule PlausibleWeb.Api.ExternalStatsController doparams = Map.put(params, "property", nil)+ params =+ if Map.get(params, "interval") == "date" do+ %{params | "interval" => "day"}+ else+ params+ end+with :ok <- validate_period(params),:ok <- validate_date(params),:ok <- validate_interval(params),@@ -316,7 +323,7 @@ defmodule PlausibleWeb.Api.ExternalStatsController dodefp validate_period(_), do: :ok- @valid_intervals ["date", "month"]+ @valid_intervals ["day", "month"]@valid_intervals_str Enum.map(@valid_intervals, &("`" <> &1 <> "`")) |> Enum.join(", ")defp validate_interval(%{"interval" => interval}) dodiff --git a/lib/plausible_web/controllers/api/stats_controller.ex b/lib/plausible_web/controllers/api/stats_controller.exindex 8204abda2d..5cb549f5d2 100644--- a/lib/plausible_web/controllers/api/stats_controller.ex+++ b/lib/plausible_web/controllers/api/stats_controller.ex@@ -137,7 +137,6 @@ defmodule PlausibleWeb.Api.StatsController docomparison_plot: comparison_result && plot_timeseries(comparison_result, metric),comparison_labels: comparison_result && label_timeseries(comparison_result, nil),present_index: present_index,- interval: query.interval,includes_imported: includes_imported?(query, comparison_query),imports_exist: site.complete_import_ids != [],full_intervals: full_intervals@@ -273,7 +272,7 @@ defmodule PlausibleWeb.Api.StatsController doEnum.find_index(dates, &(&1 == current_date))- "date" ->+ "day" ->current_date =Timex.now(site.timezone)|> Timex.to_date()diff --git a/test/plausible/stats/interval_test.exs b/test/plausible/stats/interval_test.exsindex 36e3c68093..c18771edf3 100644--- a/test/plausible/stats/interval_test.exs+++ b/test/plausible/stats/interval_test.exs@@ -6,13 +6,13 @@ defmodule Plausible.Stats.IntervalTest dotest "default_for_period/1" doassert default_for_period("realtime") == "minute"assert default_for_period("day") == "hour"- assert default_for_period("7d") == "date"+ assert default_for_period("7d") == "day"assert default_for_period("12mo") == "month"endtest "default_for_date_range/1" doassert default_for_date_range(Date.range(~D[2022-01-01], ~D[2023-01-01])) == "month"- assert default_for_date_range(Date.range(~D[2022-01-01], ~D[2022-01-15])) == "date"+ assert default_for_date_range(Date.range(~D[2022-01-01], ~D[2022-01-15])) == "day"assert default_for_date_range(Date.range(~D[2022-01-01], ~D[2022-01-01])) == "hour"end@@ -23,14 +23,14 @@ defmodule Plausible.Stats.IntervalTest doassert valid_by_period(site: site) == %{"realtime" => ["minute"],"day" => ["minute", "hour"],- "7d" => ["hour", "date"],- "month" => ["date", "week"],- "30d" => ["date", "week"],- "6mo" => ["date", "week", "month"],- "12mo" => ["date", "week", "month"],- "year" => ["date", "week", "month"],- "custom" => ["date", "week", "month"],- "all" => ["date", "week", "month"]+ "7d" => ["hour", "day"],+ "month" => ["day", "week"],+ "30d" => ["day", "week"],+ "6mo" => ["day", "week", "month"],+ "12mo" => ["day", "week", "month"],+ "year" => ["day", "week", "month"],+ "custom" => ["day", "week", "month"],+ "all" => ["day", "week", "month"]}end@@ -40,13 +40,13 @@ defmodule Plausible.Stats.IntervalTest doassert valid_by_period(site: site) == %{"realtime" => ["minute"],"day" => ["minute", "hour"],- "7d" => ["hour", "date"],- "month" => ["date", "week"],- "30d" => ["date", "week"],- "6mo" => ["date", "week", "month"],- "12mo" => ["date", "week", "month"],- "year" => ["date", "week", "month"],- "custom" => ["date", "week", "month"],+ "7d" => ["hour", "day"],+ "month" => ["day", "week"],+ "30d" => ["day", "week"],+ "6mo" => ["day", "week", "month"],+ "12mo" => ["day", "week", "month"],+ "year" => ["day", "week", "month"],+ "custom" => ["day", "week", "month"],"all" => ["week", "month"]}end@@ -58,12 +58,12 @@ defmodule Plausible.Stats.IntervalTest doassert valid_by_period(site: site, from: ago_13m, to: Date.utc_today()) == %{"realtime" => ["minute"],"day" => ["minute", "hour"],- "7d" => ["hour", "date"],- "month" => ["date", "week"],- "30d" => ["date", "week"],- "6mo" => ["date", "week", "month"],- "12mo" => ["date", "week", "month"],- "year" => ["date", "week", "month"],+ "7d" => ["hour", "day"],+ "month" => ["day", "week"],+ "30d" => ["day", "week"],+ "6mo" => ["day", "week", "month"],+ "12mo" => ["day", "week", "month"],+ "year" => ["day", "week", "month"],"custom" => ["week", "month"],"all" => ["week", "month"]}@@ -73,22 +73,22 @@ defmodule Plausible.Stats.IntervalTest dodescribe "valid_for_period/3" dotest "common" dosite = insert(:site)- assert valid_for_period?("month", "date", site: site)+ assert valid_for_period?("month", "day", site: site)refute valid_for_period?("30d", "month", site: site)refute valid_for_period?("realtime", "week", site: site)endtest "for a newly created site" dosite = build(:site, stats_start_date: Date.utc_today())- assert valid_for_period?("all", "date", site: site)+ assert valid_for_period?("all", "day", site: site)- assert valid_for_period?("custom", "date",+ assert valid_for_period?("custom", "day",site: site,from: ~D[2023-06-01],to: ~D[2023-07-01])- assert valid_for_period?("custom", "date",+ assert valid_for_period?("custom", "day",site: site,to: ~D[2023-06-01],from: ~D[2023-07-01]@@ -97,15 +97,15 @@ defmodule Plausible.Stats.IntervalTest dotest "for a newly created site with >12m range" dosite = build(:site, stats_start_date: Date.utc_today())- assert valid_for_period?("all", "date", site: site)+ assert valid_for_period?("all", "day", site: site)- refute valid_for_period?("custom", "date",+ refute valid_for_period?("custom", "day",site: site,from: ~D[2012-06-01],to: ~D[2023-07-01])- refute valid_for_period?("custom", "date",+ refute valid_for_period?("custom", "day",site: site,to: ~D[2012-06-01],from: ~D[2023-07-01]@@ -114,9 +114,9 @@ defmodule Plausible.Stats.IntervalTest dotest "for a site with stats starting over 12m ago" dosite = build(:site, stats_start_date: Timex.shift(Date.utc_today(), months: -13))- refute valid_for_period?("all", "date", site: site)+ refute valid_for_period?("all", "day", site: site)- assert valid_for_period?("custom", "date",+ assert valid_for_period?("custom", "day",site: site,from: ~D[2023-06-01],to: ~D[2023-07-01]diff --git a/test/plausible/stats/query_parser_test.exs b/test/plausible/stats/query_parser_test.exsindex a3372f3ec8..8ab002eb6f 100644--- a/test/plausible/stats/query_parser_test.exs+++ b/test/plausible/stats/query_parser_test.exs@@ -10,11 +10,11 @@ defmodule Plausible.Stats.Filters.QueryParserTest do@date_range Date.range(@today, @today)def check_success(params, site, expected_result) do- assert {:ok, ^expected_result} = parse(site, params, @today)+ assert {:ok, ^expected_result} = parse(site, Map.put(params, "date", @today))enddef check_error(params, site, expected_error_message) do- {:error, message} = parse(site, params, @today)+ {:error, message} = parse(site, Map.put(params, "date", @today))assert message =~ expected_error_messageend@@ -358,7 +358,7 @@ defmodule Plausible.Stats.Filters.QueryParserTest do]}- assert {:ok, res} = parse(site, params, @today)+ assert {:ok, res} = parse(site, Map.put(params, "date", @today))expected_timezone = site.timezoneassert %{diff --git a/test/plausible/stats/query_test.exs b/test/plausible/stats/query_test.exsindex 39f3d66fd7..ee0517cbdf 100644--- a/test/plausible/stats/query_test.exs+++ b/test/plausible/stats/query_test.exs@@ -57,7 +57,7 @@ defmodule Plausible.Stats.QueryTest doassert q.date_range.first == ~D[2019-01-01]assert q.date_range.last == ~D[2019-01-31]- assert q.interval == "date"+ assert q.interval == "day"endtest "parses 6 month format", %{site: site} do@@ -138,7 +138,7 @@ defmodule Plausible.Stats.QueryTest doassert q.date_range.first == Timex.today() |> Timex.shift(days: -1)assert q.date_range.last == Timex.today()assert q.period == "all"- assert q.interval == "date"+ assert q.interval == "day"endtest "all time shows monthly if site is more than a month old", %{site: site} do@@ -174,7 +174,7 @@ defmodule Plausible.Stats.QueryTest doassert q.date_range.first == ~D[2019-01-01]assert q.date_range.last == ~D[2019-01-15]- assert q.interval == "date"+ assert q.interval == "day"end@tag :ee_onlydiff --git a/test/plausible_web/controllers/api/external_stats_controller/timeseries_test.exs b/test/plausible_web/controllers/api/external_stats_controller/timeseries_test.exsindex bf8b39e73e..ade31d28de 100644--- a/test/plausible_web/controllers/api/external_stats_controller/timeseries_test.exs+++ b/test/plausible_web/controllers/api/external_stats_controller/timeseries_test.exs@@ -84,7 +84,22 @@ defmodule PlausibleWeb.Api.ExternalStatsController.TimeseriesTest do}end- test "validates that interval is `date` or `month`", %{conn: conn, site: site} do+ test "legacy `date` interval is overridden to `day`", %{conn: conn, site: site} do+ conn =+ get(conn, "/api/v1/stats/timeseries", %{+ "site_id" => site.domain,+ "date" => "2021-06-30",+ "period" => "6mo",+ "interval" => "date"+ })++ results = json_response(conn, 200)["results"]++ assert Enum.at(results, 0)["date"] == "2021-01-01"+ assert Enum.at(results, 1)["date"] == "2021-01-02"+ end++ test "validates that interval is `day` or `month`", %{conn: conn, site: site} doconn =get(conn, "/api/v1/stats/timeseries", %{"site_id" => site.domain,@@ -94,7 +109,7 @@ defmodule PlausibleWeb.Api.ExternalStatsController.TimeseriesTest doassert json_response(conn, 400) == %{"error" =>- "Error parsing `interval` parameter: invalid interval `alskd`. Valid intervals are `date`, `month`"+ "Error parsing `interval` parameter: invalid interval `alskd`. Valid intervals are `day`, `month`"}endend@@ -1822,7 +1837,7 @@ defmodule PlausibleWeb.Api.ExternalStatsController.TimeseriesTest do"site_id" => site.domain,"period" => "custom","date" => "2021-01-01,2021-01-01",- "interval" => "date",+ "interval" => "day","metrics" => "conversion_rate","filters" => "event:goal==Signup;event:page==/register","with_imported" => "true"diff --git a/test/plausible_web/controllers/api/stats_controller/main_graph_test.exs b/test/plausible_web/controllers/api/stats_controller/main_graph_test.exsindex db0d0e440a..bfecd730b6 100644--- a/test/plausible_web/controllers/api/stats_controller/main_graph_test.exs+++ b/test/plausible_web/controllers/api/stats_controller/main_graph_test.exs@@ -531,7 +531,7 @@ defmodule PlausibleWeb.Api.StatsController.MainGraphTest doconn =get(conn,- "/api/stats/#{site.domain}/main-graph?period=7d&date=2021-01-07&metric=visitors&interval=date"+ "/api/stats/#{site.domain}/main-graph?period=7d&date=2021-01-07&metric=visitors&interval=day")assert %{"plot" => plot} = json_response(conn, 200)@@ -861,7 +861,7 @@ defmodule PlausibleWeb.Api.StatsController.MainGraphTest doconn =get(conn,- "/api/stats/#{site.domain}/main-graph?period=6mo&date=2021-06-01&metric=visitors&interval=date"+ "/api/stats/#{site.domain}/main-graph?period=6mo&date=2021-06-01&metric=visitors&interval=day")assert %{"plot" => plot} = json_response(conn, 200)@@ -923,7 +923,7 @@ defmodule PlausibleWeb.Api.StatsController.MainGraphTest doassert %{"error" =>- "Invalid value for interval. Accepted values are: minute, hour, date, week, month"+ "Invalid value for interval. Accepted values are: minute, hour, day, week, month"} == json_response(conn, 400)end