From 2cf42629290bd738028ccacf204215d32738f377 Mon Sep 17 00:00:00 2001 From: Nick Grato Date: Thu, 2 Nov 2023 07:44:21 -0700 Subject: [PATCH] formatting: --- client/pages/analytics/index.tsx | 1 - lib/dash.ex | 24 +++++++------------ lib/dash/hub_stat.ex | 1 - .../api/v1/analytics_controller.ex | 10 +------- lib/dash_web/router.ex | 7 ------ 5 files changed, 10 insertions(+), 33 deletions(-) diff --git a/client/pages/analytics/index.tsx b/client/pages/analytics/index.tsx index 01628bde..4853c5da 100644 --- a/client/pages/analytics/index.tsx +++ b/client/pages/analytics/index.tsx @@ -89,7 +89,6 @@ const Sandbox = ({ analytics }: SandboxPropsT) => { const compareHubsP1Set = new Set(compareHubs.p1); const compareHubsB0Set = new Set(compareHubs.b0); - // Check how many id's did not make it to the compare set const p0Persistant = hubs.p0.filter((id) => compareHubsP0Set.has(id)); const p0Gained = compareHubs.p0.filter((id) => !hubsP0Set.has(id)); diff --git a/lib/dash.ex b/lib/dash.ex index ac0db281..c44845a8 100644 --- a/lib/dash.ex +++ b/lib/dash.ex @@ -315,36 +315,30 @@ defmodule Dash do def subdomain_wait(), do: Application.get_env(:dash, __MODULE__)[:subdomain_wait_time] - defp clean_date_string(date) do date |> String.trim_leading("~U[") |> String.trim_trailing("]") end - def get_hubs_by_date(start_date,end_date) do - - clean_start_date = start_date |> - clean_date_string() - - clean_end_date = end_date |> - clean_date_string() + def get_hubs_by_date(start_date, end_date) do + clean_start_date = + start_date + |> clean_date_string() - # query = - # from hub in Hub, - # join: stat in assoc(hub, :hub_stats), # Correctly using the association name - # where: stat.measured_at == ^clean_date, - # select: hub + clean_end_date = + end_date + |> clean_date_string() query = - from hub in Hub, + from(hub in Hub, join: stat in assoc(hub, :hub_stats), where: stat.measured_at >= ^clean_start_date and stat.measured_at <= ^clean_end_date, select: hub + ) Repo.all(query) end - end diff --git a/lib/dash/hub_stat.ex b/lib/dash/hub_stat.ex index ad6ccb41..eec783c7 100644 --- a/lib/dash/hub_stat.ex +++ b/lib/dash/hub_stat.ex @@ -2,7 +2,6 @@ defmodule Dash.HubStat do use Ecto.Schema alias Dash.{HubStat, Repo, Hub, RetClient} - @primary_key false schema "hub_stats" do field :measured_at, :utc_datetime diff --git a/lib/dash_web/controllers/api/v1/analytics_controller.ex b/lib/dash_web/controllers/api/v1/analytics_controller.ex index 6520249e..8a21bd52 100644 --- a/lib/dash_web/controllers/api/v1/analytics_controller.ex +++ b/lib/dash_web/controllers/api/v1/analytics_controller.ex @@ -4,18 +4,10 @@ defmodule DashWeb.Api.V1.AnalyticsController do require Logger def show(conn, %{"start_date" => start_date, "end_date" => end_date} = params) do - - - hubs = Dash.get_hubs_by_date(start_date,end_date) + hubs = Dash.get_hubs_by_date(start_date, end_date) conn |> put_resp_header("access-control-allow-origin", "http://localhost:3000") |> json(%{hubs: hubs}) end - - - - - - end diff --git a/lib/dash_web/router.ex b/lib/dash_web/router.ex index 2217812f..7e03a843 100644 --- a/lib/dash_web/router.ex +++ b/lib/dash_web/router.ex @@ -26,8 +26,6 @@ defmodule DashWeb.Router do resources "/region", Api.V1.RegionController, only: [:show], singleton: true end - - scope "/api/v1", DashWeb do pipe_through :basic_auth resources "/logout", LogoutController, only: [:index] @@ -42,8 +40,6 @@ defmodule DashWeb.Router do resources "/analytics", Api.V1.AnalyticsController, only: [:show], singleton: true end - - scope "/api/v1", DashWeb do pipe_through [:api, :basic_auth, :jwt_authenticated, :approved_email_auth] @@ -57,9 +53,6 @@ defmodule DashWeb.Router do post "/hubs/validate_subdomain", Api.V1.HubController, :validate_subdomain end - - - scope "/api/v1", DashWeb do pipe_through :fxa_events_parser # TODO decode JWT tokens from FxA with a new plug