Skip to content

Commit

Permalink
formatting:
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Grato committed Nov 2, 2023
1 parent 56c9a6e commit 2cf4262
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 33 deletions.
1 change: 0 additions & 1 deletion client/pages/analytics/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
24 changes: 9 additions & 15 deletions lib/dash.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
1 change: 0 additions & 1 deletion lib/dash/hub_stat.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 1 addition & 9 deletions lib/dash_web/controllers/api/v1/analytics_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 0 additions & 7 deletions lib/dash_web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]

Expand All @@ -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
Expand Down

0 comments on commit 2cf4262

Please sign in to comment.