Skip to content

Commit a2a12db

Browse files
authored
Merge pull request #1126 from code-corps/update-scout-config
Update scout config
2 parents 4c57e7e + 4984202 commit a2a12db

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

config/scout_apm.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
use Mix.Config
55

66
config :scout_apm,
7-
name: System.get_env("SCOUT_APP_NAME") || "", # The app name that will appear within the Scout UI
8-
key: System.get_env("SCOUT_APP_KEY") || ""
7+
name: {:system, "SCOUT_APP_NAME"}, # The app name that will appear within the Scout UI
8+
key: {:system, "SCOUT_APP_KEY"}
99

1010
config :phoenix, :template_engines,
1111
eex: ScoutApm.Instruments.EExEngine,

lib/code_corps/task/query.ex

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ defmodule CodeCorps.Task.Query do
33
Holds queries used to retrieve a list of, or a single `Task` record from the
44
database, using a provided map of parameters/filters.
55
"""
6+
67
import Ecto.Query
8+
import ScoutApm.Tracing
79

810
alias CodeCorps.{Helpers, Task, Repo}
911
alias Ecto.Queryable
@@ -18,13 +20,15 @@ defmodule CodeCorps.Task.Query do
1820
"""
1921
@spec list(map) :: list(Project.t)
2022
def list(%{} = params) do
21-
Task
22-
|> Helpers.Query.id_filter(params)
23-
|> apply_archived_status(params)
24-
|> apply_status(params)
25-
|> apply_optional_filters(params)
26-
|> order_by([asc: :order])
27-
|> Repo.all()
23+
timing("Task.Query", "list") do
24+
Task
25+
|> Helpers.Query.id_filter(params)
26+
|> apply_archived_status(params)
27+
|> apply_status(params)
28+
|> apply_optional_filters(params)
29+
|> order_by([asc: :order])
30+
|> Repo.all()
31+
end
2832
end
2933

3034
@spec apply_optional_filters(Queryable.t, map) :: Queryable.t

lib/code_corps_web/controllers/task_controller.ex

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@ defmodule CodeCorpsWeb.TaskController do
44

55
alias CodeCorps.{Analytics.SegmentTracker, Task, Policy, User}
66

7+
import ScoutApm.Tracing
8+
79
action_fallback CodeCorpsWeb.FallbackController
810
plug CodeCorpsWeb.Plug.DataToAttributes
911
plug CodeCorpsWeb.Plug.IdsToIntegers
1012

1113
@spec index(Conn.t, map) :: Conn.t
1214
def index(%Conn{} = conn, %{} = params) do
13-
with tasks <- Task.Query.list(params),
14-
tasks <- preload(tasks)
15-
do
15+
tasks = Task.Query.list(params)
16+
tasks = preload(tasks)
17+
timing("JaSerializer", "render") do
1618
conn |> render("index.json-api", data: tasks)
1719
end
1820
end
@@ -21,7 +23,7 @@ defmodule CodeCorpsWeb.TaskController do
2123
def show(%Conn{} = conn, %{} = params) do
2224
with %Task{} = task <- Task.Query.find(params),
2325
task <- preload(task)
24-
do
26+
do
2527
conn |> render("show.json-api", data: task)
2628
end
2729
end
@@ -63,7 +65,9 @@ defmodule CodeCorpsWeb.TaskController do
6365
@preloads [:comments, :github_pull_request, :task_skills, :user_task]
6466

6567
def preload(data) do
66-
Repo.preload(data, @preloads)
68+
timing("TaskController", "preload") do
69+
Repo.preload(data, @preloads)
70+
end
6771
end
6872

6973
# tracking

0 commit comments

Comments
 (0)