From 503dc60b30eb982c28a4d627945da9d67ec2a4be Mon Sep 17 00:00:00 2001 From: Uku Taht Date: Mon, 17 Aug 2020 16:35:55 +0300 Subject: [PATCH] Rename Total visitors -> Unique visitors --- .../controllers/api/stats_controller.ex | 18 +++++++++--------- .../api/stats_controller/main_graph_test.exs | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/plausible_web/controllers/api/stats_controller.ex b/lib/plausible_web/controllers/api/stats_controller.ex index 13a227d57..9b9145db9 100644 --- a/lib/plausible_web/controllers/api/stats_controller.ex +++ b/lib/plausible_web/controllers/api/stats_controller.ex @@ -37,26 +37,26 @@ defmodule PlausibleWeb.Api.StatsController do defp fetch_top_stats(site, %Query{filters: %{"goal" => goal}} = query) when is_binary(goal) do prev_query = Query.shift_back(query) - total_visitors = Stats.unique_visitors(site, %{query | filters: %{}}) - prev_total_visitors = Stats.unique_visitors(site, %{prev_query | filters: %{}}) + unique_visitors = Stats.unique_visitors(site, %{query | filters: %{}}) + prev_unique_visitors = Stats.unique_visitors(site, %{prev_query | filters: %{}}) converted_visitors = Stats.unique_visitors(site, query) prev_converted_visitors = Stats.unique_visitors(site, prev_query) conversion_rate = - if total_visitors > 0, - do: Float.round(converted_visitors / total_visitors * 100, 1), + if unique_visitors > 0, + do: Float.round(converted_visitors / unique_visitors * 100, 1), else: 0.0 prev_conversion_rate = - if prev_total_visitors > 0, - do: Float.round(prev_converted_visitors / prev_total_visitors * 100, 1), + if prev_unique_visitors > 0, + do: Float.round(prev_converted_visitors / prev_unique_visitors * 100, 1), else: 0.0 [ %{ - name: "Total visitors", - count: total_visitors, - change: percent_change(prev_total_visitors, total_visitors) + name: "Unique visitors", + count: unique_visitors, + change: percent_change(prev_unique_visitors, unique_visitors) }, %{ name: "Converted visitors", 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.exs index 4f81b78b7..e6289143d 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 @@ -121,7 +121,7 @@ defmodule PlausibleWeb.Api.StatsController.MainGraphTest do ) res = json_response(conn, 200) - assert %{"name" => "Total visitors", "count" => 6, "change" => 100} in res["top_stats"] + assert %{"name" => "Unique visitors", "count" => 6, "change" => 100} in res["top_stats"] end test "returns converted visitors", %{conn: conn, site: site} do